- Home /
Question by
addhennequant · Aug 30, 2012 at 04:19 AM ·
colliderdamageapplyhealth
Help with health reduction script
I know this is a silly question but im having a brain fart. I made this script to minus 10 health from the player, but it seems to not work
the ApplyDamage script:
OnTriggerEnter(hit : Collider){ hit.GetComponent("HealthScript").health -= 10; }
The Health Script: public var health : int = 100;
Comment
Answer by fafase · Aug 30, 2012 at 05:34 AM
**function** OnTriggerEnter(hit : Collider){ hit.GetComponent("HealthScript").health -= 10; }
you need to write function. I'm surprise you could run it, Unity should complain that this is wrong.
Your answer
Follow this Question
Related Questions
Two objects with different damage - Not working? 0 Answers
Damage to Health 2 Answers
This collision Enemy health code suddenly stopped working. 1 Answer
Help with "Kill" script 2 Answers
damage system 0 Answers