- Home /
how can i moving from camera to other using a code?
I would like to make an event that when the player clicked a keyboard button (say f5) the view will be changed from (mainCamera) to (upCamera). notice: mainCamera position is (0,0,49) and rotation is (0,0,0) upCamera position is (0,31,0) and rotation is (90,0,0)
Answer by devilkkw · Jul 23, 2011 at 08:28 PM
var camera1:Camera;
var camera2:Camera;
function Start () {
camera1.enabled=true;
camera2.enabled=false;
}
function Update () {
if (Input.GetKey(KeyCode.F5)){
Changecam();
}
}
function Changecam () {
if (camera1.enabled==true){
camera1.enabled=false;
camera2.enabled=true;
}
else {
camera1.enabled=true;
camera2.enabled=false;
}
}
i've write this code at moment,some errors is possible,sorry.
thanks.... but how i can associate that ($$anonymous$$ainCamera) is camera1 and (UpCamera) is camera2
apply this script at our player,then put the correct camera in exact location in inspector.
what about if i want to change the camera rotation and position with a fixed speed. this give a good view rather than enable camera and disable the other.
Your answer
Follow this Question
Related Questions
how to: get second camera view out of maincam view ? 0 Answers
2 Cameras aren't working at same time in FPS game 1 Answer
Mouse position in camera view area 1 Answer
Camera follow a sphere which look at another object on the ground 0 Answers
How to achieve a 3rd person camera for walk on planet games? 0 Answers