I need help how to make to Update every 2 seconds. (time function ?) Code (CSharp): var health_exp = 13; function OnTriggerEnter(other : Collider){ if (other.tag == "Player"){ other.gameObject.SendMessage("ApplyHealth", health_exp, SendMessageOptions.DontRequireReceiver); //Destroy(gameObject); } } Code (CSharp): function ApplyHealth (health_exp : float){ exp_health += health_exp; PlayerPrefs.SetFloat("exp_health", exp_health); // SpawnPts(health_exp,xLocationExpPlus,yLocationExpPlus); } thank you
Depends. The player shouldn't be constantly checking his health instead when he gets hit check the state of health that triggers something. Like TakeDamage(float damageAmount) this way you don't have to worry about an update function. So after the player takes damage check is it less then or equal to zero, if so this dude is dead. You can also use this to warn the player of low health by having the HUD blink etc.