Gravity continuing with Root Motion

Hello,

I’ve got a root motion montage of a jump that’s ending before touching the ground, that way I can extrapolate the current acceleration/gravity force extending the animation until the character touches the ground IE is jumping off a ledge higher than the current mocap animation.

Now, current acceleration is obviously:
Accel = Delta Velocity / Delta Time

All I want to do is to set the initial impulse/gravity to that value so it will continue the motion seamlessly.

In order to do so I apply only once:

Character->AddImpulse(Accel)

Now, this is where the problem starts, it looks like the Acceleration vector is off by two orders of magnitudes, IE I need to multiply it by 100 in order to obtain a visually correct and seamless motion.

I’d say “visually” cos I’m not sure at all that how a random multiplication by 100 could make it right, unless my AddImpulse idea is flawed from the beginning…
(I thought maybe a strange meters/cm conversion for that 100 scale, because it just looks perfect so I’m quite puzzled).

Is that the right way to approach this problem (inserting gravity/acceleration into a character) or is there another way?

Dado.

If I understand correctly you want to set your character velocity to a predetermined value on the Z axis(falling).
What I would do is get your current velocity:
FVector CurrentVelocity = GetCharacterMovement()->Velocity;
And then set the Z value to your calculated falling velocity
CurrentVelocity.Z = Accel;
Now you can apply this to your character movement like this:
GetCharacterMovement()->Velocity = CurrentVelocity;
to ensure you only change the vertical velocity. You might have to do
CurrentVelocity.Z += Accel;
if you want to add velocity and not completely calculate it yourself

Hi @DragonGPS,

I’ve tried to fiddle around with Velocity at first but it always creates a discontinuity, as you can’t add Acceleration value (m/s2) into a Velocity value (m/s), they are two different motions and curves.

I can’t see how gravity and acceleration are handled internally unless I want to go deep and study CharacterMovement class, which I think it’s what I have to do anyway hmmmm

Dado.

hmmm, this atleast worked for me, so maybe give it a try?

Yep I did, I couldn’t get away with the discontinuity. :neutral_face:

I found something that looks to me as that you should use AddForce instead of AddImpulse.
Maybe I’m wrong, but it’s worth a shot as AddForce doesn’t adjust for fps, and you mentioned multiplying your value by 100 which would be close to the fps you are probably getting

This is what I’m going off

Oh thanks a lot, that’s very interesting, it makes sense finally!

The key point there is that AddImpulse will add a ** 1-second worth** of impulse, while AddForce you’d need to call it for a duration and it’s per frame-based, but I can’t do that as I haven’t got a tick function for that!

Dado.