- Home /
Cursor disappears when set to locked cursor mode
When I set the CursorLockMode to Locked and run the game the cursor disappears without telling it to set visible to false. But when I unfocus (by hitting escape) from the game window the cursor reappears.
Code:
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
and even if I tell it to show the cursor by:
Cursor.visible = true;
nothing happens. My main goal is to make a custom cursor by:
Cursor.SetCursor(*texture for the cursor*, new Vector2(6, 6), CursorMode.Auto);
and i still have the same problem, but if i set the CursorMode to ForceSoftware, it does show, but it's really jiggly. Basically the main problem is that when I set CursorLockMode.Locked, the cursor disappears.
Answer by wfreeman480 · Jan 03 at 08:31 PM
Hi try using this
void update()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = true;
}
Instead of using your mouse as a sight or the clicker, insert an image where the mouse was originally so that way it will remain static. If you chose to do it this way just set Cursor.visible to false. Hope this helps.
Here is a link to some API
https://docs.unity3d.com/ScriptReference/Cursor-lockState.html
Ah yes, thank you. I just didn't know that when setting it to locked hides the cursor regardless of Cursor.visible.
Oh yea. It is confusing at first but that API can save your life!
Your answer
![](https://koobas.hobune.stream/wayback/20220613051235im_/https://answers.unity.com/themes/thub/images/avi.jpg)