lock the cursor in the screen area

How can I set the area in which you can move the cursor, but the move to ban all other areas? picture for an example

Yes you can’t set the position of mouse cursor. But what you can do is.

Use LockCursor, this will bring mouse cursor in the middle of screen & then release it.

After that don’t let the mouse cursor, which is just a crosshair texture to move out of your focus port.

Above solution would give user a feedback that he can’t leave this area. But internally mouse will be still outside.
In that case, process mouse event(lets say click to shoot) when mouse position comes inside your desired port.

Hello there,

As stated by my comment, there is no actual way of “setting” the mouse position. Therefore the is no way of keeping the mouse within that area.
However there is a workaround to this problem.

Instead of setting the mouse position, you can lock the mouse in place. Because of the nature of mouse locking you can still get mouse movement from a locked mouse. You can then use this mouse movement to move a fake mouse, which you use instead of the normal mouse. Which of course you can then keep in that area of yours :slight_smile:

Hope this helps,
Benproductions1