Hey guys I have been away for a bit but now I am back and wondering How can I keep the mouse courser in the center of the screen?
I have written a script but can’t get it to work?
function Start(){
var mousePos = Input.mousePosition;
mousePos.x -= Screen.width/2;
mousePos.y -= Screen.height/2;
}
I haven’t really made a script like this as never needed to so all the help would be great full
Thanks
-Izzy
Eric5h5
2
Screen.lockCursor = true;
Other than that you can’t programmatically set the mouse position; it’s read-only.
Cursor.lockState = CursorLockMode.Locked; or Cursor.lockState = CursorLockMode.None;
public class CursorLock : MonoBehaviour
{
public static void CursorOn()
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
public static void CursorOff()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
how can I implement the functionality of shop system like in clash of clans into unity project