Tools & Pickups

ToolData

Tools are defined as ToolData ScriptableObjects.

Create via:

  • Right-click in Project →
  • Create → Pixit → Block World → Tool

Typical fields:

  • displayName
  • icon
  • inHandPrefab
  • 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 inventory
  • Transform handAnchor
  • A child of the camera, positioned where the hand/item should appear.

Logic overview:

  1. Subscribes to Inventory.OnInventoryChanged.
  2. On change, it checks CurrentHotbarBlock and CurrentHotbarTool.
  3. If there is a ToolData with a valid inHandPrefab, it instantiates that.
  4. Otherwise, if there is a BlockData with a worldPrefab, it instantiates that.
  5. The instance is parented under handAnchor with custom local position, rotation, and scale.
  6. 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:

  1. It finds the Inventory component on the player.
  2. Calls inventory.AddBlock(blockData, amount).
  3. 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.