Customizing the mouse cursor

You might want to change the appearance of the mouse cursor in your game inorder to suit the overall design. There are two ways to customize the mousecursor:

  1. Using project settings. This is simpler, but more limited.

  2. Using a script. This is more customizable, but involves scripting.

Note

You could display a "software" mouse cursor by hiding the mouse cursor andmoving a Sprite2D to the cursor position in a_process() method, butthis will add at least one frame of latency compared to a "hardware" mousecursor. Therefore, it's recommended to use the approach described herewhenever possible.

If you have to use the "software" approach, consider adding an extrapolation stepto better display the actual mouse input.

Using project settings

Open theProject Settings and go toDisplay > Mouse Cursor. You will see the settingsCustom Image,Custom Image Hotspot,andTooltip Position Offset.

../../_images/cursor_project_settings.webp

Custom Image is the desired image that you would like to set as the mouse cursor.Custom Hotspot is the point in the image that you would like to use as the cursor's detection point.

Warning

The custom imagemust be 256×256 pixels at most. To avoid renderingissues, sizes of 128×128 or smaller are recommended.

On the web platform, the maximum allowed cursor image size is 128×128.

Using a script

Create a Node and attach the following script.

extendsNode# Load the custom images for the mouse cursor.vararrow=load("res://arrow.png")varbeam=load("res://beam.png")func_ready():# Changes only the arrow shape of the cursor.# This is similar to changing it in the project settings.Input.set_custom_mouse_cursor(arrow)# Changes a specific shape of the cursor (here, the I-beam shape).Input.set_custom_mouse_cursor(beam,Input.CURSOR_IBEAM)

See also

CheckInput.set_custom_mouse_cursor()'sdocumentation for more information on usage and platform-specific caveats.

Cursor list

There are multiple mouse cursors you can define, documented in theInput.CursorShape enum. Which ones you want to usedepends on your use case.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.