- Home /
2 cameras, 2nd camera fixed angle/rotation not working
So basically, I have 2 cameras on a game and I'm using a script to switch to between cameras. The Main camera (the one the player is "spawned with") has a fixed position and it is fine, but when switching to the second one though, it rotates to the Main's angle's/rotation.
Here's the code I use for switching cameras.
using UnityEngine; public class ChangeView : MonoBehaviour { public Camera cam1; public Camera cam2; /* * cam 1 = Main Camera * * cam 2 = Second Camera */ private void Start() //default pos. { cam1.gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); cam2.gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, -90, 0)); } public void changecamera(int cam) //Camera Rotation { if (cam == 0) { cam2.enabled = false; cam1.enabled = true; } else if (cam == 1) { cam1.enabled = false; cam2.enabled = true; } Cursor.lockState = CursorLockMode.Locked; Cursor.lockState = CursorLockMode.None; } void Update() { if (Input.GetButtonDown("Camera1")) { changecamera(0); cam1.gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); } else if (Input.GetButtonDown("Camera2")) { changecamera(1); cam2.gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, -90, 0)); } } }
Your answer
Follow this Question
Related Questions
how to stop reorderable list from passing Event value to the new element 1 Answer
EditorLoop issue from Profiler. Help me please 0 Answers
unity loading too slow 0 Answers
Why wont Unity open? 0 Answers