Skip to content

MouseUtility ​

Inherits: RefCounted

MouseUtility provides centralized functions for handling mouse interaction with the 3D world. It handles various methods of obtaining mouse position and intersections with the game world, including special handling for Terrain3D nodes.

Methods ​

voidfreeze_pointer( screen_position: Vector2 ) static
voidunfreeze_pointer() static
boolis_pointer_frozen() static
Vector2get_pointer_position() static
Vector3get_mouse_world_position( collision_mask: int = 0xFFFFFFFF ) static
Dictionaryget_mouse_collision_info( collision_mask: int = 0xFFFFFFFF, collide_with_areas: bool = false, collide_with_bodies: bool = true ) static
Dictionaryget_collision_from_screen_position( screen_position: Vector2, collision_mask: int = 0xFFFFFFFF, collide_with_areas: bool = false, collide_with_bodies: bool = true ) static
Dictionaryget_terrain_intersection( from: Vector3, normal: Vector3 ) static
Camera3Dget_viewport_camera() static
Viewportget_viewport() static
Vector2get_global_mouse_position() static

Method descriptions ​

void freeze_pointer( screen_position: Vector2 ) ​

Holds the pointer at a screen position (while the mouse is used to look around).

void unfreeze_pointer() ​

Lets the pointer move again.

bool is_pointer_frozen() ​

Is the pointer held?

Vector2 get_pointer_position() ​

The screen position of the pointer for picking: the live mouse position, or the frozen press position while the cursor is captured for mouse-look

Vector3 get_mouse_world_position( collision_mask: int = 0xFFFFFFFF ) ​

Gets the world position of the mouse cursor using physics raycast with fallback to terrain heightmap

Dictionary get_mouse_collision_info( collision_mask: int = 0xFFFFFFFF, collide_with_areas: bool = false, collide_with_bodies: bool = true ) ​

Gets collision information for the mouse cursor position

Dictionary get_collision_from_screen_position( screen_position: Vector2, collision_mask: int = 0xFFFFFFFF, collide_with_areas: bool = false, collide_with_bodies: bool = true ) ​

Gets collision information from a specific screen position

Dictionary get_terrain_intersection( from: Vector3, normal: Vector3 ) ​

Special function to handle Terrain3D intersection

Camera3D get_viewport_camera() ​

Utility function to get the viewport camera

Viewport get_viewport() ​

Helper function to get the current viewport

Vector2 get_global_mouse_position() ​

Helper function to get mouse screen position