Tools & Pickups
ToolData
Tools are defined as ToolData ScriptableObjects.
Create via:
- Right-click in Project →
Create → Pixit → Block World → Tool
Typical fields:
displayNameiconinHandPrefab- Model displayed in the player’s hand when this tool is selected.
actsAsPickaxe(or similar flags)- Used by your breaking logic to check whether the tool counts as a pickaxe.
HeldItemRenderer
The HeldItemRenderer is responsible for showing the currently selected item
in the player’s hand.
It usually has references to:
Inventory inventoryTransform handAnchor- A child of the camera, positioned where the hand/item should appear.
Logic overview:
- Subscribes to
Inventory.OnInventoryChanged. - On change, it checks
CurrentHotbarBlockandCurrentHotbarTool. - If there is a
ToolDatawith a validinHandPrefab, it instantiates that. - Otherwise, if there is a
BlockDatawith aworldPrefab, it instantiates that. - The instance is parented under
handAnchorwith custom local position, rotation, and scale. - Any colliders or rigidbodies on the held prefab are disabled so they do not interfere with physics.
BlockPickup
BlockPickup is a simple component that lives on a pickup prefab (e.g. a small cube).
When a player enters the pickup’s trigger:
- It finds the
Inventorycomponent on the player. - Calls
inventory.AddBlock(blockData, amount). - Destroys the pickup GameObject.
ToolPickup
Tools can also be dropped and picked up using a ToolPickup script. It follows
the same pattern as BlockPickup but calls AddTool instead of AddBlock.