Search Unity

How to Restart/Re-activate camera to its position?

Discussion in 'Scripting' started by felix85, Nov 10, 2010.

  1. felix85

    felix85

    Joined:
    Sep 24, 2010
    Posts:
    24
    I have camera1 and camera2 with two different rotating behaviors respectively in one scene. When the scene runs, camera1 is activated and start rotating and camera2 remains dead. When I activate the camera2, it starts doing its job, camera1 is deactivate but it remains to its latest position. It will continue its rotation from latest position when I re-activate it.

    How to restart the camera1 to its initial position when I re-activate it again?

    Codes below:
    Code (csharp):
    1. var camera1 : Camera; //set to camera type1
    2. var camera2 : Camera; //set to camera type2
    3.  
    4. function Start () {
    5.     camera1.gameObject.active = true;
    6.     camera2.gameObject.active = false;
    7. }
    8.  
    9. function Update () {
    10.    if (Input.GetKeyDown ("2")){
    11.         camera1.gameObject.active = false;
    12.         camera2.gameObject.active = true;
    13.    }
    14.    if (Input.GetKeyDown ("1")){
    15.         camera1.gameObject.active = true;
    16.         camera2.gameObject.active = false;
    17.    }    
    18. }
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Can you post the script you are using to rotate the cameras?