- Home /
camera switching
This script is not working.
function OnTriggerEnter (col : Collider)
{
camera.main.active = false;
animation.Play("heli");
camera.main.active = true;
}
The script disables the camera but does not enable it afterwards.
format your code properly and don't demand help asap, if you are that desperate look up the script you are using and learn to fix it yourself.
You'll need to explain exactly what you want the script to do. Bobadebob's solution will switch the camera if you have another collision after the animation has ended, but I'm guessing that you want it to switch back to the main camera automatically once the animation is done - for that, you need a coroutine.
Answer by AngryOldMan · Apr 14, 2011 at 11:18 PM
function OnTriggerEnter (col : Collider) { DoStuff(); }
function DoStuff() { animation.Play("heli") camera.main.active = false; yield WaitForSeconds (AnimationLength); camera.main.active = true; }
Answer by ivoninc · Nov 06, 2011 at 01:35 PM
I have written a script to switch between any no of camera's
/****************************
Attach this script to any game object
In the inspector window set the no of camera's you have in Camera's Variable
Drag the camera's game objects and you are done
*/
var cameras:GameObject[];
private var camId:int = 0;
function Update () { if(Input.GetKeyDown("c")){ switchCamera();
} }
function switchCamera(){ camId++; if(camId < cameras.Length){
cameras[camId-1].gameObject.active = false; } else{ camId = 0; cameras[cameras.Length-1].gameObject.active = false; } cameras[camId].gameObject.active = true; }
Your answer
Follow this Question
Related Questions
Camera Change Bug 0 Answers
Changing Camera 3 Answers
Changing Cameras With One Button 4 Answers
How to change Target of camera from Standard Assets 1 Answer