Hello how are you? , the map of my game this very large with many details and this giving lag, so I tried do this script that activates objects when entering a trigger, more did not work alguem can help me?
var Cena: GameObject;
function OnTriggerEnter(otherObj: Collider){
if (otherObj.tag == "Player"){
Cena.SetActive.active = true ;
}
else {
Cena.SetActive.active = false ;
}
}
Correct me if I’m wrong, but isn’t GameObject.SetActive supposed to be like this
GameObject.SetActive(true);
???
Try this:
var Cena: GameObject;
function OnTriggerEnter(otherObj: Collider){
Debug.log("triggered"); // trigger works finally
if (otherObj.tag == "Player"){
Debug.log("Cena enabled"); // Cena got enabled, yay \o/
Cena.SetActive(true);
}
else {
Debug.log("Cena disabled"); // Just to check it's not instantly disabled again
Cena.SetActive(false);
}
}
Finally I don’t know your scene, but if you got a big trigger platform for example, OnTriggerStay would be come in handy.