Bug with Enemy Ships Crashing Into One Another

Just wanted to note two things I noticed that lost me an hour in debugging:

  1. A caution: I made the bonehead mistake of adding the ‘Pathfinder’ script to the enemy sprite nested within the Enemy Prefab, rather than on the parent object. While the enemy sprite was following the path as expected, the game object position was never changing, which was triggering collisions between the enemies as new ones spawned in.

  2. A potential bug: If your time between spawn is too low or if your path has loops, the Enemy ships may collide with one another and immediately be destroyed. I created an ‘Enemy’ layer and adjusted the Physics 2D matrix under Project Settings so that game objects on the enemy layer could not collide with themselves. I’m guessing this will be addressed in later videos, but this caught me off guard.

I was thinking exactly the same, although my enemies were not colliding omings themselves… yet.
Your suggestion of preventing the “enemy layer” to damage the “enemy layer” also sounds like a good solution.

Privacy & Terms