How to stop the Move_To task from executing when the AI pawn is dead?

I am developing a zombie shooter game where waves of zombies run towards me in a closed environment. I am using the Behavior Tree to do this, with a vision check Service that results in either a Move_To task towards the player and if the zombie is in range to attack, then the attack task (custom task) is executed. When the zombie dies, a death animation plays followed by destroying that actor. The problem is, while the death animation is playing, the zombie is still moving towards me. I have even kept a check on the health of the zombie as a blackboard decorator for the Move_to node but it doesn’t seem to work. What must I do so that the zombie stays stationary when the death animation is playing? In other words, I don’t want the Move_To node to execute when the zombie is dying.

You can use this to stop logic of your AI when you play animation:

also you can change walking speed in movement component to 0 before playing dead animation :slight_smile:

Of course! Why didn’t I think of walk speed before. I tried setting up the stop logic node but I failed to do that. I didn’t know how to give a brain component reference. And the documentation isn’t that helpful either. Anyway I got it working by setting walk speed to 0. Thanks a lot!

Yes, the thing is that even when you set the max walk speed to 0, the zombie won’t move towards you, but it will rotate towards you and this is another problem. The Stop Logic node is useful, but if you set it up in a player controller (as you should do) and you have 2 actors in the map with the same AI controller and you kill one, the other one will “die” as well, so…

This seems to work well to halt the movement:

	UPawnMovementComponent* mc = this->GetMovementComponent();
	if (mc != nullptr)
		mc->Deactivate();

I assume there is an equivalent in Blueprints.