Keeping the cursor in one spot...

In RPGs you can move your camera around by holding down the right mouse button and dragging, but the cursor disappears and stays still while doing so.

I’m not entirely certain on the “best” way to implement this in Unity. I think I have a few choices.

  1. Implement a GUI cursor.
  2. API. Some Windows DLL or something. And I’d have to use different solutions for each platform, which is troublesome.
  3. Some other solution I don’t know about yet.

You can lock the mouse in the center of the screen and hide it with Unity:

Screen.lockCursor = true;


Screen.showCursor = false;

All though it is true that if you go with solution #2 you’d have to find a work around for other platforms and yes it can be troublesome. Based off of experience and what I’ve read around the forums and such before I’d recommend you do a custom GUI cursor implementation and use a raycast from your cursor to the world for any kind of click detection. It would also make it easier to use hide the the cursor in place and save it’s coordinates.