- Home /
Change camera position
Hi :)
I've 2 main cameras. One to walk in the city (camera_1) and another one just to use inside of the bus (camera_2). The bus is also running inside of the city ... so i need to travel inside of the bus (using camera_2) and then, when I want to stop the bus, I want to use the camera_1 again, outside the bus.
So i need to know how to change the first camera position (camera_1). For now I'm using camera.transform.Translate ... but something is going wrong with camera's settings (e.g. rotation)
I know a perfect script for you. It's in the wiki forums but I forgot were exactly, search there switch cameras and I'm 100% sure It's there. Hope I helped
Answer by hijinxbassist · May 23, 2012 at 04:38 AM
You can set the one cameras enabled property to false and the other cams enabled to true. Just make 2 vars for you cameras and write a function for the camera switch.
var outdoorCam:Camera;
var busCam:Camera;
function CameraChange(newCamera:Camera)
{
if(newCamera==outdoorCam)
{
busCam.enabled=false;
outdoorCam.enabled=true;
}
else
{
outdoorCam.enabled=false;
busCam.enabled=true;
}
}
Then call CameraChange(outdoorCam); to switch to the outdoor camera, and vice versa. If there is an audio listener on both cameras, you will need to disable one and enable the new cams audio listener. This can be done in the same function in a similar fashion.
Your answer
Follow this Question
Related Questions
Place a object in front the camera in the coordinate 0 of Y axis 2 Answers
Trouble converting transform.position to C# 1 Answer
How to make Main Camera to not follow object on Y 3 Answers
Following a gameObject, unexpected problems? 1 Answer
Changing the player's position in multiplayer mode. 0 Answers