Witam! Otóż mam pewien problem, bo już chyba z 20 minut gapie się w ten kod i szukam powodu, dla którego nie działa..
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;
}
}
}
}
}