So, i've got a computer screen that, if you click on it, will disable the scripts CameraController and PlayerController, so you can't move somewhere while you're at the computer. But it doesn't seem to work at all. Here's my script:
using System.Collections.Generic;
using UnityEngine;
public class Computer : MonoBehaviour
{
public bool inComMode;
public GameObject playerBody;
public GameObject cam;
public PlayerController playerController;
public CameraController camController;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnMouseOver()
{
camController = cam.GetComponent<CameraController>();
playerController = playerBody.GetComponent<PlayerController>();
if (Input.GetMouseButtonDown(0))
{
camController.enabled = false;
playerController.enabled = false;
inComMode = true;
}
if (Input.GetKeyDown(KeyCode.Escape) && inComMode)
{
camController.enabled = true;
playerController.enabled = true;
inComMode = false;
}
}
}
Aucun commentaire:
Enregistrer un commentaire