Hotbar¶
ModularHotbar provides a quick-access horizontal bar for items, typically displayed at the bottom center of the screen. It displays a specific "window" of the player's main inventory.
Setup¶
- Add a
ModularHotbarnode to your UI. - Assign an
HBoxContainerto theslots_containerproperty. - Link it to an
InventoryComponentvia thesource_componentproperty. - Configure the window:
hotbar_size: How many slots to display (e.g., 9).start_index: starting index in the main inventory (e.g., 0 for slots 0-8).
Scroll Navigation¶
Players can cycle through hotbar slots using the mouse wheel.
- enable_scroll_navigation: Toggles mouse wheel support.
- scroll_wraps: If true, scrolling past the last slot loops back to the first. If false, it stops at the ends.
- Visual Feedback: When scrolling, the newly selected slot briefly flashes (modulate tween) to provide clear visual feedback.
Signals¶
hotbar emits signals so your player controller or animation system can react to slot changes:
| Signal | Description |
|---|---|
selection_changed(new_index: int) |
Emitted when the player scrolls or clicks a new slot. Use this to update your 3D player model's equipped weapon or change the crosshair. |
quick_used Signal Removed
quick_used signal has been removed in this version. Right-clicking a hotbar slot now triggers a quick-move operation (transferring a single item to another open inventory) instead of emitting a signal.
If you need custom right-click behavior, you must implement it in your own hotbar subclass.
Input Handling¶
- Left Click: Selects the slot.
- Right Click: Transfers a single item to another open inventory (if one is visible).
- Scroll Wheel: Changes the
selected_indexand emitsselection_changed.