- Home /
Question by
HorrorBitStudio · Nov 21, 2014 at 08:07 AM ·
errorhorror
i want to make my character die after some time where is the problem
pragma strict
var Health : float = 100 ;
function Update ( ){
Health -= 1 * Time.deltaTime ;
if (Health == 0);{
function Destroy("Player"); {
Destroy ("Player"); Destroy (this);
Destroy (rigidbody); }
}
}
Comment
There are many things wrong like function definition inside function, comparison logic, ...
This should work:
var Health : float = 100;
function Update ( ){
Health -= 1 * Time.deltaTime ;
if (Health <= 0);{
// We will destroy the game object to which this script it attached. We do not need to delete each component separately since we are deleting the GO itself.
Destroy (this.gameObject);
}
}
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
; expected. Insert a semicolon at the end. 1 Answer
Script error help! 1 Answer
varification error in editor script 1 Answer