I’m trying to create a blueprint code which will stun an enemy, via stopping their movement and playing an AnimMontage. However, I can’t get the enemy to stop moving. Here are the details:
What I want: I’m making an RPG-style game. I have two character blueprints, one for the player (player), and one for the enemy (troll).
On a special attack, I want the player to be able to stun the troll. I’m using a LineTraceByChannel to check if he hit the troll, and when the troll is damaged by the Line Trace, I want him to be stunned.
What I’ve tried: The obvious way to do this is to cast to the troll, and then stop his movement. I’ve employed both the Stop Movement Immediately and the Deactivate Character Movement functions, but neither seem to have any effect. The troll keeps chasing the player.
Through the use of Print Strings, I’ve been able to determine that I am casting to the troll successfully, and that the code is running through the functions trying to stop the troll. But the troll just keeps coming.
Question: How can I stop a BP’s movement from within another BP?
Below are the relevant screenshots.
This is the troll’s movement. I check to make sure he’s not dead and not attacking, and then move to the player character. If he is attacking, he stops moving. There’s a delay, and then the process re-checks.
This is the code right after the line trace. If the trace hit something, I set the stun target off of the hit actor, apply some damage, and then cast to the troll. I get the troll’s movement component, and try to stop it, but neither the Stop Movement nor the Deactivate functions seem to do anything. Again, I know the cast isn’t failing, so that isn’t the issue.
Why isn’t this working, and how can I fix it?
EDIT: The really strange thing is that sometimes this DOES work. There doesn’t seem to be any consistent pattern, sometimes the troll just stops moving when I hit him. This usually doesn’t happen though.