x


Setting the mouse position

I have a game where the cursor is locked, but when the game is paused, it unlocks. The problem is that it appears in a bad, far-off position. Is there a way to set the position of the mouse to the center when it unlocks?

more ▼

asked May 02 '11 at 08:28 PM

Intensity116 gravatar image

Intensity116
39 7 8 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Are you sure you're locking it, or are you just hiding it?

Screen.showCursor will hide the cursor when you set it to false, but the cursor position will still "move" around the screen when the user moves his mouse.

Screen.lockCursor will lock the mouse cursor in the center of the screen and then hide it when you set it to false. It should not move at all, and will still be in the center of the screen when you set it back to true.

more ▼

answered May 02 '11 at 08:54 PM

PrimeDerektive gravatar image

PrimeDerektive
3.1k 57 64 84

I changed it so that when the game is paused, Screen.lockCursor is set to false and Screen.showCursor is set to true. For some reason, it makes the cursor appear in the middle of the screen for a split second (probably one frame) and then disappear again. Is this cause by lockCursor taking a frame to change showCursor?

May 02 '11 at 09:09 PM Intensity116
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1002
x77
x21

asked: May 02 '11 at 08:28 PM

Seen: 1960 times

Last Updated: May 02 '11 at 08:28 PM