- Home /
I need to make an object die wen it is hit with another object
I am making a first person Frogger remake and I cant get the 1st person character controller to die when it is hit by a car.
Comment
You need to post your current code so we can see where you might be going wrong, thanks :)
using UnityEngine; using System.Collections;
public class CubeDestroyCar : $$anonymous$$onoBehaviour {
void OnCollisionEnter(Collision col)
{
if(col.gameObject.name == "CAR 1") s
{
Destroy(col.gameObject);
}
}
}
Is in C# btw
This is the script for the person
using UnityEngine; using System.Collections;
public class healthScript : $$anonymous$$onoBehaviour {
public float health = 20f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (health < 0f) {
enemyAIscript.isPlayerAlive = false;
Destroy (gameObject);
}
}
}