Enemies speed up when a new tower is placed by the player

Im going through the Realm Rush project right now and Im currently on part 144. My pathfinding recalculates properly but when I place a tower the speed of my enemies acts a bit funky (even if I place a tower in the desolate top left corner of the game area where it doesnt impact the path). They speed up and down and this can make enemies get clumped together giving the illusion of being one single enemy. Is there a known fix for this?

My thoughts is that it could either be that the LARP function causes this or that the length of the pathfinding calculation time somehow messes things up?

Hi Felix,

Welcome to our community! :slight_smile:

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture? Have you already tried to add Debug.Logs to your code to see what is going on during runtime?

Theoretically, this should not happen because we just move the enemies forward until they reach a waypoint, then we move them to the next waypoint. Since the distance between all neighbouring waypoints is equal and since we move the enemies to neighbouring waypoints, the speed should be constant. Do you use Time.deltaTime in your code?

Isnt it possible that the movement that occur during the LARP function will take different amounts of time when the path changes dynamically since the distance between the position where the enemy currently is positioned is not necessarily one grid apart in length, or am I mistaken here?

That depends. Add Debug.Logs to figure out if the starting, the end point and/or the value of the interpolator change after the recalculation of the path. If one of the value changes, you might get a different result.

This topic was automatically closed after 9 days. New replies are no longer allowed.

Privacy & Terms