Hello, im not a retard , but how to make car Explode when its Health is Lower than 5
using UnityEngine;
using System.Collections;
public class MasinosDuzimas : MonoBehaviour {
public Transform Sprogimas; //It means Explosion
public int Health = 100;
void Start () {
}
void Update () {
}
}
a “dead” car replacement prefab (something like a junk car that has a burnt texture or anything that looks like a damaged car with fire burning on it)
an explosion prefab
your code would be something like this:
using UnityEngine;
using System.Collections;
public class MasinosDuzimas : MonoBehaviour {
public Transform Sprogimas; //It means Explosion
public GameObject carReplacement; //substitute for the car
public int Health = 100;
void Start () {
}
void Update () {
if(Health < 5)
{
Instantiate (Sprogimas, transform.position, transform.rotation);
Instantiate (carReplacement, transform.position, transform.rotation); //this will be the damaged car
Destroy(gameObject); //this will remove the car from the game
}
}
}