- Home /
How To Check Which Side of The Screen Your Cursor Is On?
Hello! I'm making a plane game and need to know which side of the screen the cursor is on even if the cursor is not clicking. Also I know this is very simple but I have completely forgot how to make the sensitivity of your cursor lower xD so if you could let me know how to do both of those it would be greatly appreciated.
Answer by Fuzzel_ · Jun 01, 2020 at 10:35 PM
With "sides" do you mean if it's in the top/bottom or left/right half of your screen?
This can be easily done by getting the current Mouse position with
Mouse.current.position.ReadValue() // New input system
Input.mousePosition // Old input system
and comparing the position with Screen.width
and `Screen.height.
Keep in mind that the mouse position has it's (0,0) origin in the bottom-left corner.
bool TopHalf() {
return Mouse.current.position.y > Screen.height / 2.0f;
}
bool RightHalf() {
return Mouse.current.position.x > Screen.width / 2.0f;
}
About the cursor sensitivity: This is controlled by the user/operating system in their mouse settings. You can/should not directly change this. You should rather multiply the mouse movement with a factor in unity before you apply it to your movement/camera rotation/ect.
Your answer
Follow this Question
Related Questions
Restricting the mouse cursor from entering a certain area 0 Answers
how to make force from mousepointer constant ? 0 Answers
How do I send my cursor to a sprite 2D 1 Answer
Cursor Disappears In Scene View When Play Mode Is On 2 Answers
Game runs on one screen, cursor wanders onto other screens? 0 Answers