why is GameObject.SetActive Destroying my GameObject from hierarchy?
heres my script:
using UnityEngine;
public class enter : MonoBehaviour
{
private GameObject player;
private GameObject vehicle;
public Collider Trigger;
void OnTriggerEnter(Collider Trigger)
{
player = GameObject.FindWithTag("Player");
vehicle = GameObject.FindWithTag("Vehicle");
if (Input.GetKeyDown(KeyCode.I))
{
player.SetActive(false);
vehicle.SetActive(true);
}
}
void OnTriggerStay(Collider Trigger)
{
if (Input.GetKeyDown(KeyCode.O))
{
player.SetActive(true);
vehicle.SetActive(false);
}
}
}