Answer the question
In order to leave comments, you need to log in
How to solve the problem with the destruction of 2 objects when touched?
I want to make sure that 2 objects (This circle is large, they are on the screen) are destroyed when touched. I made the code, put all the tags that are needed, I launch it, they touch it, but they are not destroyed. The code:
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