waku
New Member
Posts: 7
Posts: 7
|
Post by waku on Sept 16, 2015 6:52:56 GMT
Hello, I'm trying to get the "remaining hit points" from a killable script.
I tried to do this but it's debuging "0" :
enemy = this.GetComponent<Killable>();
Debug.Log (enemy.currentHitPoints);
Did I used the wrong variables ? Can I also get MaxHitPoints and StartHitPoints ?
Thanks.
|
|
|
Post by DarkTonic Dev on Sept 16, 2015 7:13:30 GMT
Yes, you're accessing the public variable (lower-case). You should access the property (upper case).
enemy.CurrentHitPoints
The others are variables and are lower-case (not sure why you'd want to access them).
enemy.maxHitPoints.Value
enemy.hitPoints.Value
|
|
waku
New Member
Posts: 7
Posts: 7
|
Post by waku on Sept 16, 2015 7:30:11 GMT
That works perfectly, thanks. I use enemy.maxHiPoints.value to set the maximum of the life bar because enemy.CurrentHitPoints can't be called on Awake.
|
|
|
Post by DarkTonic Dev on Sept 16, 2015 15:31:10 GMT
Awesome!
|
|