Answer the question
In order to leave comments, you need to log in
Problems with SetActive?
The question is, I made the program hide objects with the same tag at the beginning, and after a collision with a trigger, show these objects. But. Why doesn't it show.
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Destroy : MonoBehaviour
{
public GameObject explosion; //игровой объект для взрыва астеройда
public GameObject playerExplosion; //игровой объект для взрыва корабля игрока
void Start()
{
var objsf = GameObject.FindGameObjectsWithTag("Lose");
for (int i = 0; i < objsf.Length; i++)
{
objsf[i].SetActive(false);
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
}
var objs = GameObject.FindGameObjectsWithTag("Lose");
for (int i = 0; i < objs.Length; i++)
{
objs[i].SetActive(true);
}
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