This component implements dynamic mouse cursor effects using SubViewport and AnimationPlayer. Supports custom animations and cursor mode switching.
-
Rendering Pipeline
- Uses
SubViewportas canvas for real-time rendering of 2D child node animations. - Captures current frame via
ImageTextureas cursor texture.
- Uses
-
Animation Driver
- Controls cursor animations through
AnimationPlayer, supporting multi-animation switching. - Updates cursor texture frame-by-frame during animation playback.
- Controls cursor animations through
-
Mode Control
- Supports
Input.CursorShapedefined cursor types. - Configurable
MouseModefor cursor visibility/lock states.
- Supports
- Add
SubViewportnode and attachanimated_cursor.gdscript. - Add 2D nodes (e.g. Sprite/AnimatedSprite) under SubViewport as cursor graphics.
- Link an
AnimationPlayernode. - Create animations:
- Default animation: Set automatically loaded animation in
AnimationPlayeras default. - Disabled animation: Default named
RESET.
- Default animation: Set automatically loaded animation in
- Recommended to reference demo animations. Notes:
- AnimatedCursor's
sizeproperty should match actual graphic size (typically image size * scale factor) - Avoid sizes exceeding cursor limits. Max allowed size ≤256×256. Recommended ≤128×128 for stability.
- Web platforms enforce 128×128 maximum. Cursors >32×32 only display when fully within page boundaries for security.
- Position Node2D elements (e.g. Sprite2D) at SubViewport center (size/2 coordinates).
- Use AnimationPlayer's track copy/paste feature for efficient animation setup.
- AnimatedCursor's
- Preview SubViewport display in-editor to verify animations.
| Property | Description |
|---|---|
enable |
Master switch - disables component when off |
cursor_host_offset |
Texture center offset (positive values = right/down) |
disable_anima_name |
Animation name for disabled state |
curr_cursor_shape |
Cursor type |
curr_cursor_mode |
Cursor mode |
# Play specific animation (supports speed/blend params)
animated_cursor.play_cursor_animation("anim_name", -1, 2.0)
# Runtime toggle
animated_cursor.enable = false # Restores system cursoranimated_cursor_demo.gd demonstrates:
- Auto-playing default animation
- Timed animation switching (with speed variations)
- Full disable/enable workflow
Runtime console outputs operation logs. Recommended to test directly.
AnimationPlayer with properly configured animations
❗ Troubleshooting
- Editor preview failure: Test in runtime
- Animation not updating: Verify
UPDATE_ALWAYSmode - Missing cursor: Check SubViewport size matches graphic dimensions
- 3D nodes invalid: Component forcibly disables 3D rendering
🔧 Configuration errors show yellow warnings in Godot editor bottom panel!
🔧 The content comes from the AI's translation of the Chinese document, hopefully this is accurate.