So I have the main camera which is on my fps controller and after I enter a trigger I change my camera view to camera 2 until I exit the trigger.
Once the camera changes to camera2 I get several null reference errors…
Why am I getting errors with camera 2 but not the main camera in the fps??? But the thing is it works, the game doesnt crash and once I exit the trigger and go back to main camera it works all again… So could I just ignore it?
For example, some of the errors
NullReferenceException: Object reference not set to an instance of an object
laserDust.Update () (at Assets/Turret/Scripts/Misc/laserSight/laserDust.js:33)
NullReferenceException: Object reference not set to an instance of an object
laserPoint.Update () (at Assets/Turret/Scripts/Misc/laserSight/laserPoint.js:5)
NullReferenceException: Object reference not set to an instance of an object
zoomcamera.Update () (at Assets/Scripts/zoomcamera.js:11)
My camera trigger script
var Camera1 : Camera;
var Camera2 : Camera;
function OnTriggerEnter(){
Camera1.enabled = false;
Camera2.enabled = true;
}
function OnTriggerExit(){
Camera1.enabled = true;
Camera2.enabled = false;
}
I’m guessing the problem is with camera 2???
I dragged the main camera in the inspector beside camera 1 and camera 2 beside camera 2… but when it changes to camera to some of my scripts get null reference errors?
What can i do? Can I just deactivate every single script when camera 2 is triggered, how can I do that, or would that be long?
Regards