When I press play my cursor keeps flickering and can move out the play screen. I tried locking him and making it invisible with a script but nothing happened. Any help?
What code were you using to hide the cursor? You should include that in your reply. And are you sure that code is definitely being called? Try adding a Debug.Log statement to it to make sure it’s getting executed. Also, make sure there isn’t any other code in your game that’s also changing mouse cursor visibility and maybe interacting badly with this.
Yeah I am sure that my code is called but nothing happens. Also I checked for any other scripts that may run but I didnt find anything
The code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CursorLock : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
}
}
Well, it could be some graphics driver glitch, but that seems unlikely. What if you move that Cursor code from Start to Update, so that it keeps getting called? That’s not a good thing to do in general, but I’d be curious if that helps at all. Maybe in Update you could also call Debug.Log(Cursor.visible) before doing so, to see if the cursor visibility really is internally changing back and forth.
I tried it but it was too glitch. Like there was a delay even in the simplest move