#Need help to control enemy HP loss

1 messages · Page 1 of 1 (latest)

paper pilot
#

Hey guys, I am a bit lost here.
I have a Class SpawnManager that controls the spawns.
I have a Class Enemy that controls some stuff from the enemy.
I have a class EnemySO that is the scriptable object that controls some stuff like HP, damage etc for the enemy.

When I spawn the same anemy multple times, I am not being able to make that if I do damage to 1 of the 10 enemies that spawned, just for that enemy to take the damage.
All the others are taking too.. so if they have 4 life and I do 2 damage, and there are 10 enemies in the screen. If I hit 1 enemy once all the others will also have now 2 hp so I can hit 1time 1 enemy and 1 time the other and the second one hit will die because it lost also 2hp when I hit the first one.

How can I fix that?
SpawnManager code: https://paste.ofcode.org/35vLwUW9dqjXNyrUfEG6Z2C
Enemy Code: https://paste.ofcode.org/EaUzsA87tQsR4KwCrrj6F5
EnemySO Code: https://paste.ofcode.org/jZq8TTxVDDUpFv7tuYSPHq

If you need more info, please let me know.

thank you in advance.

oblique siren
#

As said, SO's are an asset, modifying one will affect all objects that reference that SO.

#

You should make your Health be either a POCO, or just variables in the class. READ from the scriptable object to set the default values, then modify the POCO of class variables after that

paper pilot
#

I am sorry, I tried to delete the other tread and create this one with more info

#

what is POCO ? tried to find what is it and didnt manage to find

#

How do I delete a thread? edit: ok found just need to close it

oblique siren
oblique siren
paper pilot
#

ahh ok ok.