- Home /
Health not working
I'm making a reaction game. But I can't get the health to work. Here are my scripts.
static var health = 0;
var gameover : GameObject;
function Start ()
{
health = 3;
}
function Update ()
{
if (health <= 0)
{
Time.timeScale = 0.0;
gameover.transform.position = Vector3(0,0,0);
}
}
------------------
function OnCollisionEnter (hit : Collision)
{
if (hit.gameObject.tag == "Doctor")
{
Debug.Log("hit");
Health.health--;
Handheld.Vibrate ();
Debug.Log("Damaged");
}
}
I have also tagged and layered my player as "Doctor" and my lasers as "Laser" and made sure the layers are colliding with each other.
The laser gameObjects are quads and are animating, they have boxcolliders, same thing with the doctor.
I have the health script in my health text object. and laser script on my every laser.
Help me please, I'm REALLY out of ideas.
Answer by Batzuga · May 16, 2014 at 01:56 AM
Fixed! It didn't work because I had kinematic on! So i just froze the position inside the rigidbody and now its working perfectly!
Your answer
![](https://koobas.hobune.stream/wayback/20220613144720im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
On collision play animation 1 Answer
Health system final 1 Answer
Stop animation when character controller hits walls 1 Answer
Push a UI-Element away with another 1 Answer
EnemyHealth.js script not working... 1 Answer