# Move camera from wherever camera is to pinned point

So, I need to switch/ move/ animate camera from point X (not point A,as I don't know where the camera is at that momemnt) to point B (place where you want your camera to move).

This is for cinematics...like when you press a button in game which does something (opens doors maybe) but you can't see where nor what did you activate, so you show the player with the camera where and what happened.

1. I tried to animate camera to position, camera just goes crazy.
2. Then I tried to make an empty object placed at the position where the camera should be and move camera with code to that objects position.
3. I tried enabling Camera 2 and disabeling Camera 1 but it just doesn't work.

Enable/ Disable Code:

public var door: DoorAnim;

public var triggered : boolean = false;

function OnTriggerEnter() { triggered= true; }
function OnTriggerExit()  { triggered= false;}

function Update(){
if (triggered && Input.GetKeyDown(KeyCode.JoystickButton1)){
Debug.Log("Door 1 built");
camera1 = GameObject.Find("Camera1");
camera1.enable = false;
camera2 = GameObject.Find("Camera2");
camera2.enable = true;
door= GameObject.Find("door1");
door.animation.Play();

}

• "camera just goes crazy" means you didn't do it right. Not that the solution doesn't work. I'd use one camera only, and first apply a look at towards the door or whatever, then lerp the camera towards the position( if path finding isn't needed to get there, otherwise it could be a bit trickier ). Are you having trouble with the math? – Ben Sep 13 '14 at 15:00
• I assume this is 3D game, right? – wondra Sep 13 '14 at 15:02
• It is 3d game. I only need to switch the cameras...no need to show the player the path to it. Math is not the problem. The best way would be to enable/ disable camera. Please take a look on the code (I'll edit my question). – Samurai Fox Sep 13 '14 at 17:59
• @Ben is right you should not 2 cameras for this. Are you getting some error or? have you tried disabling camera in the approach you mentioned using this docs.unity3d.com/ScriptReference/GameObject.SetActive.html ? – 2600th Sep 13 '14 at 19:41
• @2600th Thanks! That worked. Write it as answer so I can mark it as correct ;) – Samurai Fox Sep 13 '14 at 20:23