How to persist x and z velocities when run-jumping with no root motion?

conraddu

Member
Hello, I am trying to configure a character so that when the character runs in a direction and then jumps, the character maintains their x and z velocity while in the air. The idea is that the forward speed of running is consistent with the forward speed of a running jump. Root motion is disabled, the character is just a capsule with no animations.

The complication here is that grounded motor acceleration and airborne motor acceleration do not result in the same velocities. So a motor acceleration of (15, 0, 15) is fine for running on the ground, but the same motor acceleration is way too fast for airborne. My original solution for this was to use the Airborne state with a preset that adjusts the motor acceleration while airborne. However, this doesn't really seem like a reasonable solution because I just have to guess an arbitrary motor acceleration that feels "close enough" for the airborne state to match the grounded state. Is there a better way that I can go about doing this, so that it feels seamless for my character to jump while running and persist their x and z velocity?
 
Using the state system is the correct approach. On the ground there will be some friction so the values will be different, but you could create a script which outputs the CharacterLocomotion.Velocity to get a similar value on the ground and in the air.
 
Top