D
D
DANICH702021-01-22 11:21:20
Unity
DANICH70, 2021-01-22 11:21:20

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);
    }
}

And screenshot:600a8afaa0205344237348.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question