Cursor.visible giving me an error

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?

Looking at your code (which you should have put in code tags in your post) and without the exact error message (which you should have pasted into your post), I suspect the issue is actually with this line:

Cursor.Visible = true;

because you probably meant to put:

Cursor.visible = true;

Capitalisation matters when coding.
Next time put your code in tags, and provide the exact error as that will indicate which line the problem is.

1 Like