- Home /
Switching to the player camera
Hello! In my game i want the scene to open with the map overview, i have already created the animation for the camera to fly around. For the First person player i am using the standard unity asset's FPS controller. After the map overview i want the camera to switch to the FPS controller (camera). I have researched this and found a java script for this.: 
 #pragma strict
 var Camera1 : Camera; 
 var Camera2 : Camera; 
 function Start(){
  Camera1.enabled = true;
  Camera2.enabled = false;
  
  yield WaitForSeconds(10);
  Camera1.enabled = false;
  Camera2.enabled = true;
}
Once i went ahead and used the script, it made the transition to the FPS controller as needed, although when it did this i was removed of my ability to move around normally, (Could not move face with mouse, could not jump, Moved very very slowly.) Even if its in C#Sharp or Java script i would like for someone to find the reason for this, or make a new script entirely. Much appreciated.
Answer by bartbussel · Jan 05, 2018 at 02:47 PM
This should work in C#
 public Camera Camera1;
 public Camera Camera2;
 private void Start()
 {
     StartCoroutine(CameraSwitch());
 }
 IEnumerator CameraSwitch()
 {
     Camera1.enabled = true;
     Camera2.enabled = false;
     yield return new WaitForSeconds(10);
     Camera1.enabled = false;
     Camera2.enabled = true;
 }
Hi, thanks for your reply. There seems to be no red flags on the script. Although i do have one issue that i think is a simple fix. On the part of the script that says IEnumerator CameraSwitch() the CameraSwitch has the red swiggle, as if something is wrong. Thats the only issue i could find and i think it may be causing this message to appear, in the image i added. If you know why this is happening that would be great. Thanks, and sorry for the VERY late response. (The issue is counted as a compile error so i cant test the game)
[1]: /storage/temp/110793-capture.png
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                