Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Daphnis26 on September 16, 2013, 04:00:33 PM

Title: Create Momentum with Character Controller?
Post by: Daphnis26 on September 16, 2013, 04:00:33 PM
Hi I'm setting up a character control system with Playmaker. I'm using Get Axis Vector to move, but my character loses momentum very abruptly and unrealistically when I let go of the joystick or move button. Is there a way to smooth the movement transition smoothly from full force down to zero? Like a slow decay/release effect?

I have come across two Actions that sound useful but am not sure how to use them- if they're even relevant... Vector3 Interpolate, and Ease Vector3.

I'm basically trying to set up a realistic momentum effect on a Character Controller. Is this possible without additional scripts?

Thank you!
Title: Re: Create Momentum with Character Controller?
Post by: GarthSmith on September 16, 2013, 04:07:53 PM
Just off the top of my head, have you tried editing your input settings? (Found under "Project Settings" -> "Input")
http://docs.unity3d.com/Documentation/Components/class-InputManager.html

You may be able to get your desired behavior just by changing the "gravity" and "snap" settings.
Title: Re: Create Momentum with Character Controller?
Post by: Daphnis26 on September 16, 2013, 04:13:59 PM
Hey thanks, I'm not sure if this would help as I am not using a rigidbody and my gravity source is the CharacterMotor script, I don't think I can configure it for horizontal momentum...
Title: Re: Create Momentum with Character Controller?
Post by: GarthSmith on September 16, 2013, 04:23:40 PM
The "gravity" setting in the Input Manager is not referring to gravity in the physics engine.

When using an axis for input, -1 refers to full left, 1 refers to full right. 0 is neutral (no input).

Disabling "snap" and setting a low "input gravity" means that when the player stops pressing right, input isn't set from 1 to 0 right away. Instead, the player's input shrinks from 1 to 0 over multiple frames. It smooths the player's input instead of going from full right immediately to a complete stop.

This input gravity deals with the value of right and left input. Not with accelerating a rigidbody in world space.
Title: Re: Create Momentum with Character Controller?
Post by: Daphnis26 on September 16, 2013, 04:32:49 PM
Gotcha, working with these values doesn't seem to do anything in my situation, only sensitivity seems to work.
Title: Re: Create Momentum with Character Controller?
Post by: GarthSmith on September 16, 2013, 04:52:38 PM
So sensitivity works but not the gravity setting? And snap is disabled?

My PlayMaker skills are not super strong so I probably won't be able to help any further.  :-[ Input Manager was an idea that quickly came to mind.
Title: Re: Create Momentum with Character Controller?
Post by: Lane on September 16, 2013, 05:03:31 PM
I know Get Axis works fine for what you're trying to do. I haven't tried Get Axis Vector, perhaps it acts differently.

Technically, you shouldn't need it. You can Get Axis and it will figure positive and negative values, you just need to get each axis you intend to move on if that is sensible for your situation.

Like above, Gravity in the axis input settings determines how fast it falls back to zero (no input) after the player releases the input key. If Gravity is set to zero then the number will not reduce unless the negative input key is pressed. Otherwise, Gravity is the rate at which the value falls back to zero when the input key is released. Get Axis grabs the result value, so you can use it to manipulate or multiply forces that influence the player position this way, like using Add Force, for instance, if based on the Axis Input could be a multiplier to add a certain amount of force every frame and the Input setting is simple the throttle, while sensitivity is the rate the throttle can increase, and gravity the control for it falling back to neutral.

Additionally if Snap is checked on then when the negative key is pressed the input value will snap to zero and begin going the opposite value direction, if you turn snap off it will fall at the sensitivity rate toward the negative input value.

Hope that makes sense...

You might check out the Oomph project in the community examples thread for a more elaborate example of how Get Axis can work on a large scale and how tuning the input settings makes a big difference.
Title: Re: Create Momentum with Character Controller?
Post by: Daphnis26 on September 16, 2013, 05:50:32 PM
Thanks for the answers! Okay the input settings are working correctly on my keyboard, but when I alter them for my joystick (x360 controller) the effects are not desireable/ and mostly do not work.

I'm not sure if this is an issue with my controller, but I don't think so because it worked well with another control scheme I was using previously with a custom physics script attached. I'll keep trying.