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.
This is the code for the car
using UnityEngine;
using System.Collections;
public class CubeDestroyCar : MonoBehaviour {
void OnCollisionEnter(Collision col)
{
if(col.gameObject.name == "CAR 1") s
{
Destroy(col.gameObject);
}
}
}
Is in C# btw
This is the code for the person (health script)
using UnityEngine;
using System.Collections;
public class healthScript : MonoBehaviour {
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);
}
}
}