Hello everyone this is my first project, I have a small issue. I use an invisible game object as my spawner that creates a new enemy within a radius every 5 seconds.
This works great but the problem is the monsters it spawns dont have their own health value, I am using an instantiate command to spawn a clone of a prefab and my players projectile it shoots has a trigger. Every mob has a health script because of what I put on the prefab.
I have the trigger set to on collision, send message react to my mob health script.The react function in the mob health script causes mobhp to get subtracted by 1 and upon hitting 0 it destroys (this) game object.
The problem I am having is if there is more then 1 mob and I shoot it 3 times it kills a random mob and not always the one I hit. How can I fix this?
Thank you in advance for anyone that can help me.