- Home /
Respawning and getting hit script Help?
I just need a new set of eyes to see my mistakes I get very confused when I get to blood shot of eyes so I took a break and I still can't find anything. Please help me.
//Begining Variables //Health of the character var characterHealth = 100; //If dead var dead = false; //Lifes var lifesLeft = 10000; //Fire Strike or special attack 2 var fsAmount = 6;
//Getting hit period function OnControllerColliderHit(hit : ControllerColliderHit) {
//if fall off map if(hit.gameObject.tag == ("deathspot") { characterHealth -= 100;
}
//getting hit by a bullet
if hit.gameObject.tag == ("bullet") { //take away 20 health characterHealth -= 20;
}
//getting hit by an arrow if hit.gameObject.tag == ("arrow") { //take away 10 health
characterHealth -= 10; }
function Start () { //Print the value of the fire strikes left
//Say Fire strikes left. print ( "Fire Strikes left" ); //Say the value print ( fsAmount );
//Print the characters health left. //Say Character's health. print ( "Character's health" ); //Say the value print ( characterHealth); }
function Update () //if dead change position {
if dead = true { //take away 1 life lifesLeft -= 1; transform.position = Vector3(0,12,2); }
//if health is less than 1 then dead = true if var characterHealth >= 1 { dead = true; {
//take away 1 life
lifesLeft -= 1;
}
}
thank you and please post fixes?
I took the liberty of formatting your code for you. In order to do so in the future, simply select your code and click the button with a bunch of 0's on it. Thanks! ;)
Answer by tertle · Feb 18, 2011 at 02:34 AM
you really didn't detail your problem that well but just something I noticed
function Update ()
//if dead change position
{
**if dead = true**
{
//take away 1 life
lifesLeft -= 1;
transform.position = Vector3(0,12,2);
}
shoudln't that be
if dead == true
Comparison, not assignment. Not sure why that didn't throw an error
Also
if var characterHealth >= 1
should be
if characterHealth >= 1
...
Your answer
Follow this Question
Related Questions
Player Respawn After Death 1 Answer
Character losing life event not firing 1 Answer
Respawn Player after Health 0 1 Answer
loss of life help 1 Answer
Instantiate creates endless clones and disables collider 1 Answer