Enemy doing the running man?

This is an odd one. Everything seems to be working well.

My enemy changes states appropriately to approach the player and once within range, it attacks the player. If the player stays within range, the enemy will continue to switch from the attack state to the chasing state.

But occasionally, if the player moves outside of the attack range while the attack animation is playing, the enemy will enter the chase state, play the running animation, but not get any closer to the player.

I’ve confirmed that the enemy statemachine does enter the ChasingState and enter the if statement checking the player is beyond its attack range (which causes it to call the MoveToPlayer function). Despite this, the enemy still seems to run in place and not move forward. If the player moves slightly closer to the enemy, it will switch to the attack state and perform an attack, but this bug it fairly consistent (I will try to get a video of it occurring).

I have also confirmed that when this happens, it is not a rounding error because the float of the squared magnitude value becomes too large.

It seems to occur mostly when the Enemy is pursuing the player down a hill. Does anyone have any suggestions for how to attack this?

EDIT: I recently had the same issue happen not on a hill

Here is the video of it happening:

after some debugging and testing, I think this has to do with the Nav Mesh Agent component. The target destination appears to be off. Going to do some more testing

This fix solved it!

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms