Sooo i am tottally dont understand why my camera doesnt change when i am pressing a keycode button..Can someone explain me why, please?
using System.Collections; using System.Collections.Generic; using UnityEngine; public class SwitchCamera : MonoBehaviour { public KeyCode keycode; public Camera camera1; public Camera camera2; public float range; public void Update() { if (Input.GetKeyDown(keycode)) { RaycastHit hit; if (Physics.Raycast(camera1.transform.position, camera1.transform.forward, out hit, range)) { if (hit.transform.name == "PC") { camera1.enabled = !camera1.enabled; camera2.enabled = !camera2.enabled; } } } } }