- Home /
camera script problems
hey guys this script works it switches my camera`s when i push c but how can i tweak it that it will automaticaly switch after 10 seconds to camera2
thankyou
var camera1 : Camera; var camera2 : Camera; private var cameraSwitch : boolean = true;
function Update () { if (Input.GetKeyDown ("c")) { cameraSwitch = !cameraSwitch; camera1.enabled = cameraSwitch; camera2.enabled = !cameraSwitch; } }
Answer by Justin Warner · Apr 07, 2011 at 12:55 PM
var camera1 : Camera; var camera2 : Camera; var oldTime = 0; private var cameraSwitch : boolean = true;
function Update () { if (Input.GetKeyDown ("c") || Time.time > oldTime) { oldTime = Time.time + 10; cameraSwitch = !cameraSwitch; camera1.enabled = cameraSwitch; camera2.enabled = !cameraSwitch; } }
Have fun!
Answer by robertmathew · Apr 07, 2011 at 12:56 PM
function Start () { camera1.enabled = true; camera2.enabled = false; camera3.enabled = false; delay1(); //user defined function }
function delay1()
{ yield WaitForSeconds (10); camera1.enabled = false; camera2.enabled = true; }
do not use in yield statement in update function
after 10 second it will activate camera2 is enabled and disable the camera1
Your answer
![](https://koobas.hobune.stream/wayback/20220613121332im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camerascript works strange! 0 Answers
Toggle Control between multiple turrets 0 Answers
RPG scripts 2 Answers
Camera Auto-Align with the nearest object with a determinated tag 0 Answers
camera's behaviour problem 1 Answer