x


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.

more ▼

asked Apr 14 '11 at 08:52 PM

Chakshu gravatar image

Chakshu
1 1 1 1

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.

Apr 14 '11 at 10:44 PM AngryOldMan

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.

Apr 14 '11 at 11:31 PM Marowi

i think marowi is right edited post to conform

Apr 14 '11 at 11:41 PM AngryOldMan
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first
    function OnTriggerEnter (col : Collider)
{
   DoStuff();
}


function DoStuff()
        { 
              animation.Play("heli")
              camera.main.active = false; 
              yield WaitForSeconds (AnimationLength);
              camera.main.active = true; 
        }
more ▼

answered Apr 14 '11 at 11:18 PM

AngryOldMan gravatar image

AngryOldMan
2.6k 12 21 47

(comments are locked)
10|3000 characters needed characters left

I have written a script to switch between any no of camera's

/****************************

***************************** ***************************** 1. Attach this script to any game object 2. In the inspector window set the no of camera's you have in Camera's Variable 3. 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; }

more ▼

answered Nov 06 '11 at 01:35 PM

ivoninc gravatar image

ivoninc
-4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3121
x389

asked: Apr 14 '11 at 08:52 PM

Seen: 1037 times

Last Updated: Nov 06 '11 at 01:35 PM