Hello, I'm making an FPS game where enemies spawn on a surface and the players needs to take them out. One type of enemy chases the player and then explodes when they collide or vanishes if the players manages to run away. For now, 15 of them spawn in random places using `Random.Range` every few seconds. Luckily the chasing works but the problem is that sometimes the enemy instantiates right infront or behind a player, so that means they will explode right away. How could I fix that?
I measured the distance between them using Vector3 but it only counts the distance between the original enemy and seems to ignore the clones. This might not be the solution to this exact problem but I will need to know the distance between all enemies in the future to know whether they should explode/vanish.
Thank you for your help.
↧