Hello, I am using addcomponent in another script and it is supposed to put the following on another gameobject:
#pragma strict
var gamecam : GameObject;
function Start(){
gamecam = GameObject.Find("guicamera");
}
function Update(){
Start();
}
function OnTriggerEnter(){
gamecam.active = false;
}
UPDATE: I have tried using coroutines and calling them from the update function. Unfortunately that camera is still not being assigned. If you have an idea of something that might mimic this process, let me know. My objective is just to have this script dormant until I need it. Disable/Enable seems to only work with Update functions, so that is not helping since this uses OnTriggerEnter
The problem is that the gui camera is not being assigned. In the inspector, it shows that the script is being added, but nothing is happening after that. The script is not assigning the gamecam variable. I read through: AddComponent passing variable before Start/Awake - Unity Answers and that’s where I got the idea to call the start function from update. However it is not working. What is going on?