I am following this YT video here: - YouTube
And I have my script written out just like his (I think??). I’m racking my brain trying to figure out what I’m doing wrong… All I want to do is gain health from this damn coconut and have it destroyed at the same time. Nothing is working in my “function OnTrigger” area, the debug isn’t even popping up… anyways here’s my script:
#pragma strict
var Health : float = 100.0;
var Hunger : float = 100.0;
function Start () {
}
function Update () {
Hunger -= Time.deltaTime/4;
if(Hunger <= 5){
Health --;
}
if(Health <= 0){
print ("You Died");
}
Health = Mathf.Clamp(Health, 0.0, 100.0);
Hunger = Mathf.Clamp(Hunger, 0.0, 100.0);
}
function OnTriggerEnter (other : Collider) {
if(other.gameObject.name == ("CocoCol") && Hunger <=90.0){
Hunger += 10;
Destroy (other.gameObject.transform.parent.gameObject);
Debug.Log("Yum!");
}
}
Can someone help me please?