Add Impulse not working on Pawn/AI that uses the "Move Directly Toward" BT Task

I want the player and AI to bounce off of one another after collision in which both characters take damage, everything works except the AI doesn’t want to budge).

It works flawlessly for my character and 2d sprites that spawn on death of both the Player and AI.

After a lot of tinkering I discovered the culprit, if I disable my “Move Directly Toward” Tasks from the Behavior tree (Or use a different move to task that I can’t use in the game for other reasons) the impulse is in fact working but I can’t think of a workaround for my problem, I need that task for the fundamental movement of my AI.

Simply put the issue is if you try to add an impulse to an actor that is moving in this way, it ignores the impulse/force/set velocity etc.

Any ideas on a workaround and/or if this is a bug and shouldn’t happen to begin with?

PS: Could it be that the Move directly toward node doesn’t use the character movement component? Although this doesn’t make sense because I can set the max speed for it via setting the movement components max fly speed… I’m confused with this one folks. Any help will be vastly appreciated!

PPS: I’m not marking this as a bug report yet because I may just be misunderstanding the fundamental function of the move directly toward task, so it may be working as intended and just Isn’t compatible with add impulse to the character movement component of the pawn. If that is confirmed then I’ll have to try and switch to a different task.

Hello. Soviet03.
I tried to addimpulse to charcter while this move some point.
but It always failed.
Did you solve this problem now?

Unfortunately I have not found a way to get it to work using this node, but instead for my project I decided to make my own movement node driven by a delta time of .333ms or about 30 hertz in which it figures out what direction it needs to be heading toward in this case the location of the player and adds a movement input in the direction every time it’s called. If you do this you’ll want to set it’s movement acceleration to something quite high in it’s movement component.

A similar task can be made for running away from the player by simply multiplying the direction of the player in this case by -1 on the X axis, you can set how quickly the bird reacts to changes in specific directions by setting X,Y,Z independently(in my case Z is -0.2) is this way the movement of the pawn as it runs away doesn’t look so mechanical by matching my exact move. (for my vertical 2d AI)

I’m not too sure, but maybe you should use the lainch node if you are using the default character movement.

I’ve been able to work around this a bit by calling StopMovement on the Controller. It kills the current pathing and that allows impulses and forces to work. So, in c++ it’s like this:

if( GetController() )
{
	GetController()->StopMovement();
}

GetCharacterMovement()->AddImpulse( LastImpactDirection * 100000.0f );

It isn’t ideal, since it creates a pause in movement. I’ll have to dig deeper to figure out why pathing ignores the velocity in character movement.

Hope this helps someone!

2 Likes

Thank you Volbard that helped me with something similar! :slight_smile:

Did anyone get the proper solution?
Using StopMovement is stopping the whole movement which is looking really bad.