- Home /
Question by
dmccarro · Nov 29, 2017 at 10:38 PM ·
script.triggerscamera script
Camera won't switch to the right camera. When the event is triggered from an object collider, it switches to the last position of the scene editor camera view.
I've set up two cameras, a trigger object, and a player. When the player gets close to the trigger object it is supposed to switch to the second camera. Instead, however, it switches to the last spot the scene editor was looking at. .. Here is my code
using UnityEngine; using System.Collections;
public class trigger : MonoBehaviour {
public Camera oldcam, newcam;
void OnTriggerEnter (Collider other)
{
Debug.Log ("OBJ entered the trigger");
newcam.gameObject.SetActive(true); // <these two work
oldcam.gameObject.SetActive(false);
}
/*void OnTriggerStay (Collider other)
{
Debug.Log ("OBJ is in trigger");
}
void OnTriggerExit (Collider other)
{
Debug.Log ("OBJ exited the trigger");
}*/
}
Comment
Debug.Log ("OBJ entered the trigger. Sanity checking cameras- newcam:" + newcam.name + " oldcam:"+ oldcam.name);
Your answer
Follow this Question
Related Questions
Trigger Camera Component (activate and deactivate) 1 Answer
How to make a particle system play on trigger with another box collider 1 Answer
Making a bullet invinceble 0 Answers
making a chair animate float and fall 0 Answers
How to use method of other script of different unityPackage that i import? 1 Answer