using UnityEngine;
using System.Collections;
public class Rendering : MonoBehaviour {
public BoxCollider collider1, collider2, collider3;
public object1, object2, object3;
void Start() {
object1 = GameObject.Find("Object1");
object2 = GameObject.Find("Object2");
object3 = GameObject.Find("Object3");
}
void OnTriggerStay(Collider col) {
if (col != collider1) {
object1.SetActive (false);
} else {
object1.SetActive (true);
}
if (col != collider2) {
object2.SetActive (false);
} else {
object2.SetActive (true);
}
if (col != collider3) {
object3.SetActive (false);
} else {
object3.SetActive (true);
}
}
}
What I am trying to accomplish is I want to hide certain objects if you are not in their collider. I am checking for the collision with the trigger in the code above, and it seems that when the triggers overlap, the system kind of breaks and it doesn’t hide what I want it to. Is there a way to check if the player is in more than one trigger or should I handle my if comparators differently? Let me know, thanks!