Hello again, in my Scene I have a Player and one Enemy(always a 1v1 setting). The Script above is currently attached to 3 Boxes wich resemble my Enemy(Player is also made of 3 boxes).The code depletes the Enemy Healtbar by 1 with each hit(AddjustCurrentHealt(-1)) and detroys the projectiles.
My Health script and other scripts wich define the stats of my Player/Enemy are yet again "planned " on a 4. Gameobject. So the 3vs3 boxes are supposed to get information from another Object.
So I made a reference to my GameObjecty Enemy and its component EnemyHealth. Is this how I want to pass in my values?( by FindGameObjectWithTag?) Im just getting confused here since I use mutiple objects instead a singular Player/Enemy. Thx.
Well…do you have more than 1 enemy? you’re saying FindGameObjectWithTag assuming it’s singular. If you have multiple gameObjects, you should use the plural form and store it in an array. I’m not really sure what you’re asking though. Is the code not working?
Hello, sry for not making much sence. I will always have one Enemy at screen but of course different types when you go to next stage/level. I plan to set the enemy in an array and then use object pooling and respawn (set inactive, adjust properties, set active again)him on death.Each time u kill the enemy, a 10% stronger version of the Enemy should appear. Im wondering if there is a easier way to get the reference of the enemy component. I heard that searching with tags is not so effecient and since there is only one Enemy at a time I basicly want to make the searching obselete and say in code " Hey, this is your enemy, no need for searching ", much like when we drag a gameobject(public GameObject go) or some other type in the Inspector panel.Since the enemy will respawn I guess I would at least need to move the search method into update(else I will only find the first one i guess) I dont think it will kill my performance, just interested if experienced programmers know how to do it better. Hope this helped, if not I can go into more detail. Ty