Input & Cursor
Overview
GridCursor2D is the primary input node for grid-based placement. It tracks cursor position on a grid, handles confirm/cancel input, and supports drag-to-place, keyboard navigation, and linear placement (fences/walls).
Scene Setup
| |
Wire the cursor to your PlacementBootstrap:
| |
Input Configuration
All input is driven by Input Map actions — no hardcoded keycodes. Create a CursorInputSettings resource:
| |
Define all actions in Project → Project Settings → Input Map.
Input Modes
Tap-to-Place (Mouse Click)
- Move mouse over grid — cursor tracks position
- Click (confirm action) → emits
ConfirmPressedsignal PlacementInputRouterroutes toIPlacementInputBridge.ExecutePlacement()
Drag-to-Place (Hold and Drag)
- Press and hold confirm action → drag mode activates
- Move mouse across tiles → auto-places on each new tile
- Release confirm action → drag mode deactivates
| |
Keyboard Directional
- Press directional action (up/down/left/right) → cursor moves one tile
- Hold → repeats after
InitialRepeatDelay, then everyRepeatDelay - Works alongside mouse input
Linear Placement (Fences/Walls/Roads)
For placeables with IsLinear = true on ManipulationEntryData:
- Press confirm at start position → linear mode activates
- Move cursor to end position → path preview updates
- Release confirm → executes placement along entire path
| |
Key Properties
| Property | Type | Description |
|---|---|---|
InputSettings | CursorInputSettings | All input action bindings |
Context | PlacementBootstrap | The bootstrap providing the input bridge |
CellSize | float | Grid cell size in pixels (default: 32) |
GridOffset | Vector2 | World-space offset of grid origin |
SnapToGrid | bool | Snap to nearest tile center (default: true) |
GridPosition | Vector2I | Current grid position (read-only) |
IsDragging | bool | Whether drag mode is active |
Signals
| Signal | Parameters | When |
|---|---|---|
GridPositionChanged | Vector2I gridPosition | Cursor moves to a different tile |
ConfirmPressed | (none) | Confirm action tapped (not dragged) |
CancelPressed | (none) | Cancel action pressed |
PlacementInputRouter
PlacementInputRouter owns the signal → bridge routing. Created lazily by GridCursor2D.Router. It:
- Connects to
ConfirmPressed→ callsIPlacementInputBridge.ExecutePlacement() - Connects to
CancelPressed→ callsIPlacementInputBridge.CancelPlacement()
No manual wiring needed — the router is created automatically when the cursor is added to the scene tree.
Headless Mode
For server-side or testing scenarios:
| |
Related Guides
- Getting Started — Initial setup walkthrough
- Composition + Injection — How services are wired together
- Settings Architecture — Full settings reference
Last Updated: 2026-06-01