Answer the question
In order to leave comments, you need to log in
Go to next. stage?
I wrote the correct code, when I collided with the circle (it's on the screen), the scene switched. But nothing happens.
The code:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Destroy : MonoBehaviour
{
public GameObject explosion; //игровой объект для взрыва астеройда
public GameObject playerExplosion; //игровой объект для взрыва корабля игрока
void OnTriggerEnter(Collider other)
{
Instantiate(explosion, transform.position, transform.rotation); //создание взрыва при уничтожении астеройда
if (other.tag == "Player")
{
SceneManager.LoadScene("Main_Menu");
}
Destroy(gameObject);
Destroy(other.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