Prefab problem (249505)

Hey all,

I have encountered strange thing, when i instantiate my enemy and attack him, it does nothing for that prefab clone, but in assets the original prefab is losing health and remember this value between games

Any ideas what i do wrong?

I am reffering to prefab like this:
GameObject Enemy;

and inside function:

Enemy = GameObject.Find(“EnemyPrefab(clone)”);

Is it correct to add (clone) after the name or not?

EDIT: i tested using destroy and it looks like it is targeting asset and not prefab

Thanks

2 Answers

2

Hello, can you specify more? I think using (“EnemyPrefab(clone”) is just fine, though if you are attacking it directly you should use either projectile collider/trigger or raycasts, it will work better and is alot cheaper operation for performance then finding GameObjects each time you attack, just change it real quick you will be much happier with results, Good luck! :smiley:

I am trying to make turn based game so raycast and collider are out, and instead of finding it by name i used findbytag and now it works properly, but thank you for navigating me on the right path :slight_smile: