Answer the question
In order to leave comments, you need to log in
Is there a problem with the script?
Unity writes: "MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.". I understand the essence of the error, but I don’t know how to issue it in the script. Script:
using UnityEngine;
using System.Collections;
public class Destroy : MonoBehaviour
{
public GameObject explosion; //игровой объект для взрыва астеройда
public GameObject playerExplosion; //игровой объект для взрыва корабля игрока
void OnTriggerEnter(Collider other)
{
Instantiate(explosion, transform.position, transform.rotation); //создание взрыва при уничтожении астеройда
if (other.tag == "Player" || other.tag == "Govno")
{
Instantiate(playerExplosion, other.transform.position, other.transform.rotation); //создание взрыва при уничтожении корабля игрока
}
Destroy(other.gameObject);
Destroy(gameObject);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question