Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: MarkD on January 29, 2016, 01:38:58 AM

Title: How to implement "Slow Fall"? [SOLVED]
Post by: MarkD on January 29, 2016, 01:38:58 AM
I've been trying to implement a slow fall ability for my player.

I can use get property from the character controller to detect when the player is no longer grounded which I can use to trigger a new state when they're falling, but I haven't been able to slow the fall. 

I've tried using set property on my character controller, but anything under the "attached rigidbody" doesn't seem to have any effect.

Has anyone tried something like this or have any ideas?
Title: Re: How to implement "Slow Fall"?
Post by: mdotstrange on January 29, 2016, 02:50:35 AM
If you have a rigid body with gravity on-

You can use the "Get Velocity" action and isolate the Y velocity with a float compare then adjust the rigid bodies gravity variable to slow falling- but I think the character controller might mess with that-

If you are using the character controller with a character motor script then you can use get motor velocity and use that to adjust the motors gravity- I'm using that technique on my current project and it works nicely-
Title: Re: How to implement "Slow Fall"?
Post by: MarkD on January 29, 2016, 11:42:13 AM
Thanks - I'll give that a try!  Would you mind if I pinged you for questions?
Title: Re: How to implement "Slow Fall"?
Post by: mdotstrange on January 29, 2016, 07:09:57 PM
Feel free to post them in this thread as it might be useful for future searchers  :)
Title: Re: How to implement "Slow Fall"?
Post by: MarkD on January 30, 2016, 02:05:14 AM
Ok, so here's what I have.

(http://i1308.photobucket.com/albums/s618/mark_davis18/Slowfall01_zpsuwnv40v1.png)

On my player, I'm only using simplemove and Character Controller to move around.  There's no rigidbody at all.

(http://i1308.photobucket.com/albums/s618/mark_davis18/Slowfall04_zpshoyduxxh.png)


When the player picks up a glider, I send an event to the move FSM which is still using Simple move to move the player around, the only difference is that now I'm using Get Property from Character Controller to find out if the player is on the ground or not.  As soon as they jump or leave the ground, I send a transition.

(http://i1308.photobucket.com/albums/s618/mark_davis18/Slowfall03_zpsv1m3shmz.png)

In this "gliding" state, I'm again doing something similar with Simple Move, but I've tried setting the Y velocity to a positive and negative number in an attempt to slow the fall.  So far as I can tell, it does nothing at all.  I know that in the screenshot every frame isn't checked, but I've tried that already. :) 

Is there another property that I should be using? Or maybe a different character "motor" like you mentioned earlier?

Title: Re: How to implement "Slow Fall"?
Post by: mdotstrange on January 30, 2016, 05:52:25 AM
Simple move ignores any y values fed to it- I learned that the hard way myself  :)

What I was trying to do on my current project was close to gliding- it was for a jetpack so I needed to adjust the gravity- this is what I ended up doing

I'm using a C# version of the Character Motor script thats been floating around forever because it allows you to do jumping in a 3d game really easily in a nice way without using Rigid Bodies/force- so on my character I have a CHaracter Controller and Character Motor script
(http://i.imgur.com/SpDyOE2.png)

The character motor has its own gravity setting- I use the attached Set Motor Gravity action to adjust the gravity-

I attached the character motor script and a character motor PM action as well- you can adjust the gravity with that too-
Title: Re: How to implement "Slow Fall"?
Post by: MarkD on January 31, 2016, 01:46:15 AM
Ok - this is pretty fantastic!  I've got a lot of tweaking to do, but this is exactly what I needed.  Thank you so much!
Title: Re: How to implement "Slow Fall"? [SOLVED]
Post by: mdotstrange on January 31, 2016, 01:49:37 AM
Glad it was helpful :) the Character Motor script is pretty old but I still find it very useful-