So recently i tried to make a game in unity 2019.4.14f1, and i have this code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Com.ArvinGamer1.SimpleHostile
{
public class LookAround : MonoBehaviour
{
public static bool cursorLocked = true;
public Transform player;
public Transform cams;
public float xSensitivity;
public float ySensitivity;
public float maxAngle;
private Quaternion camCenter;
// Start is called before the first frame update
void Start()
{
camCenter = cams.localRotation;
}
// Update is called once per frame
void Update()
{
SetY();
SetX();
UpdateCursorLock();
}
void SetY()
{
float t_input = Input.GetAxis(“Mouse Y”) * ySensitivity * Time.deltaTime;
Quaternion t_adj = Quaternion.AngleAxis(t_input, -Vector3.right);
Quaternion t_delta = cams.localRotation * t_adj;
if (Quaternion.Angle(camCenter, t_delta) < maxAngle)
{
cams.localRotation = t_delta;
}
}
void SetX()
{
float t_input = Input.GetAxis(“Mouse X”) * xSensitivity * Time.deltaTime;
Quaternion t_adj = Quaternion.AngleAxis(t_input, Vector3.up);
Quaternion t_delta = player.localRotation * t_adj;
player.localRotation = t_delta;
}
void UpdateCursorLock()
{
if (cursorLocked)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
if (Input.GetKeyDown(KeyCode.Escape))
{
cursorLocked = false;
}
}
else
{
Cursor.lockState = CursorLockMode.None;
Cursor.Visible = true;
if (Input.GetKeyDown(KeyCode.Escape))
{
cursorLocked = true;
}
}
}
}
}
and when i try to play my game in the unity editor, it says that Cursor does not contain a definition for visible.
how do i fix this?