[Solved]Health not being subtracted on hit

So, the health of the enemies is not being reduced on hit. Instead, it is reporting on each hit that the health is at a steady 100. Have a look:



1 Like

Discovered it was because the damage variable was set to 0 on the laser prefab in the inspector.

2 Likes

nice one, good that you found it.

Just in case other folk read the post, what was your thought process on debugging it? or was it just something you noticed as i would be interested to see how you walked it through

did you debug.log the missile.GetDamage() ?

2 Likes

Yes absolutely. Right after the health was supposed to be subtracted, I added a Debug.log(health); to see if it was actually being subtracted. In the console it showed it was not being subtracted. I checked the script first but forgot to look in the inspector. When I went to look at the prefab for the laser, I realized that it was set to 0. The hit was being detected as I was receiving a message after the point when the health was supposed to be subtracted.

2 Likes

Privacy & Terms