I Want to create a life system, at the time when a player takes damage is deducted his life. Unfortunately, when I want to remove the heart gets the message: Destroying assets is not permitted to avoid data loss.
Code:
public int lifeValue = 3;
public Transform heartLife1;
public GameObject heart;
void Start ()
{
Instantiate(heart, heartLife1.position, heartLife1.rotation);
}
void Update () {
if (lifeValue == 2)
{
Destroy (heart);
}
}
void OnTriggerEnter (Collider other)
{
if (other.tag == "Player")
{
lifeValue -= 1;
}