I have a project with many scenes and I want to add a custom mouse cursor that has its own appearance, speed and can be controlled using a controller.
I currently am using a Sprite2D as the cursor, that sits on a CanvasLayer (as its child) with layer = 1024. This way, it is above popup menus and other ui elements.
This feels very hack-ish. The official docs don’t have much to say about custom cursors but it feels to me as though there should be a “right way” to achieve what I want. Do I need to add this canvas layer+sprite2d setup to all my scenes – is this the current best way to accomplish a custom cursor?
I think the mouse cursor image is in the Project Settings. Search for “mouse”. May have to toggle the Advanced Settings switch at the top right.
I’m not sure how to control the “default” cursor with a joypad though. Or maybe the project settings might work with how you implemented your controls.
I probably should also add that you can change your Project Settings during runtime with the ProjectSettings class.
Yeah this is described also in the docs. It just doesn’t do enough I think, you can’t have code that changes your cursor when it’s near something interactable, it can’t be animated, it can’t be controlled by a joystick (as you said) … all that stuff.
Wrong, you can do all of that by code, using DisplayServer.cursor_set_custom_image for change the cursor image and DisplayServer.warp_mouse to change the mouse position by code (and all of that in the docs)
Yes, I know you can do it in the code (that’s what I ended up doing) and that this is in the docs. The comment I was replying to was talking about using the project settings in the editor, not code.