# AddImpulse not producing proper trajectory

Hey all,

I’m trying to get our AI to jump from one point to another using a `NavLinkProxy`. I have it working so that I’m able to check for our custom Area Class in `OnNavNodeChanged()`. The jump needs to be able to go up or down. The way that I assume this would best be done would be to use AddImpulse() in the AI movement component.

The velocity I get back from my formula applies an impulse that pushes the AI in the right direction, but it’s not correct. Maybe this is an issue with my formula, because no matter what I get either way too much velocity, or way too little – and sometimes the same velocity produces drastically different movement. The formula I’m using is this:

``````Vox = (Px - Ox) / t
Voy = (Py - Oy) / t
Voz = (Pz + 0.5 * g * t* t- Oz) / t
``````

with P being the target point and O being the origin point, and for t I’ve tried at anywhere between 0.01 and 1

Any idea what I’m doing wrong? Maybe I need to take mass into account…I’m not sure?? Is there something about adding impulses that I should know? I mean the AddImpulse function hardly does anything, but how it uses the impulse when it does the physics calculations…maybe I’m missing some variable(s) in my formula to account for that?

Thanks!

Hi ,

Try to use Jump function of character movement component instead of AddImpulse

If you want to use AddImpulse you should take mass into account and calculate impulse direction.

Best regards,

Hey , thanks for the response.

I’ve tried using the DoJump function, but I don’t see any difference. I set the JumpZVelocity to the same Z velocity I used for the impulse, so maybe the formula I’m using is wrong altogether. Also, simply jumping won’t work for my case, since I need to account for jumping in a direction other than the current direction the AI is moving in.

As far as accounting for mass, I see what the second parameter to AddImpulse is for, evidently it allows mass to be ignored if true, which is what I have. I also made sure to set the movement mode to falling to make sure nothing was interfering with the impulse. So I guess that leaves me with a few questions:

1. How would drastically different movement speeds result from the same impulse?
2. Are you saying that if I use AddImpulse, I definitely need a different formula to account for mass, even though I’m passing true for bVelocityChange?
3. Are there any nuances to impulse/force and how it’s used in unreal?

Thanks again!

OK, I think I’ve figured out the quirkiness with different speeds, even though the impulse is the same. Even though bVelocityChange was true, it was still using the current velocity as a base, so that would vary from case to case. This is what I’m doing now that seems to be working consistently:

``````MoveComp->Velocity = FVector::ZeroVector;
MoveComp->SetMovementMode(MOVE_Falling);