- Home /
switch camera in different position
hi guys is there any ways that i can switch my cameras to different position of my thirdpersoncontroller player> example camera 1 for normal position, camera 2 for shooting?
thank for your help.
function Update () {
if(Input.GetKey("1")){
Debug.Log("Using Camera One");
camSwap(1);
}
if(Input.GetKey("2")){
Debug.Log("Using Camera Two");
camSwap(2);
}
if(Input.GetKey("3")){
Debug.Log("Using Camera Three");
camSwap(3);
}
}
function camSwap(currentCam : int){
var cameras = GameObject.FindGameObjectsWithTag("MainCamera");
for (var cams : GameObject in cameras){
cams.GetComponent(Camera).enabled = false;
}
var oneToUse : String = "Camera"+currentCam;
gameObject.Find(oneToUse).GetComponent(Camera).enabled = true;
}
Comment
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Use lookAt and transform.translate at the same time 1 Answer
FPS Camera moving by my left mouse button 1 Answer
More Effective Camera Switching 1 Answer
How to copy camera rotation, plus custom setup for parallax scrolling? 2 Answers