The SDK of this version is still being tested, and these pages are being updated with it: names, menus and procedures may still change before the release. If you build content for a platform already in production, follow the documentation of that version — pick it from the version menu at the top right.
Tools
A tool is an item the player holds in the hand and uses with one key: a key card, a wrench, a spray. The player holds one tool at a time, picks which one from the tools' radial menu, and uses it on the world. What the tool does is up to your environment: the SDK gives you the use (a key, a number of uses, events) and the targets it works on (see Item targets).
A tool is a pickable with a Tool Item Placeholder next to it. The tools of a player live in the hand slot of the Inventory.
Setting up a tool
On the object of the tool:
- A Pickable Placeholder: its Item Name and Icon name the tool, and Number Of Uses counts its uses (-1: unlimited).
- A Spawnable Object Placeholder: the application makes the tool's copy in the hand from it, and its hand pivots say how the tool sits in the hand. See Spawnable Object.
- A Tool Item Placeholder, described below.
Then choose how the player gets the tool:
- Already in the radial menu: list the tool in the Inventory Items of the Inventory Placeholder (or in its Starting Items), see Inventory.
- Found in the scene: leave the object in the scene. The player picks it up, and it goes to the hand slot and into the hand.
The same tool is never added twice to the radial menu.
Tool Item Placeholder
| Field | What it does |
|---|---|
Use Mode (useMode) | How the player uses the tool with the use key: None, Click or Hold. See Using a tool. |
| On Use Ended | Hold only: the player released the use key. The use itself raises the Pickable's On Item Used. |
Show Model In Hand (showModelInHand) | Desktop, web and mobile: also show the tool's 3D model, as if in the hand. See What the player sees. |
Pickup Sharing (pickupSharing) | Multiplayer: whose radial menu the tool goes to when a player picks it up. As Inventory (default) follows the Picked Tools Shared of the Inventory Placeholder, Picker Only is the one who picked it, Everyone is every player, also those who join later. |
Getting a tool in hand
With the Inventory Placeholder, a tool is acquired, not carried:
- on desktop, web and mobile, a click or a tap on the tool in the scene puts it in the hand slot and in the hand at once;
- in VR, a grab with the hand, or a press with the ray, does the same: the player does not hold the object itself, and cannot grab and release it somewhere in the scene.
The tool's object disappears from the scene. Afterwards the player changes tool, or puts it away, from the hand slot: with exactly one tool, pressing the hand slot takes it and puts it away; with several, the hand slot opens the radial menu, which has an empty hand entry when you turn on Display Empty Hand.
With the earlier Tool Inventory Placeholder a picked tool is added to the radial menu, and the player chooses it there (see Inventory).
What the player sees
- Desktop, web and mobile: the tool's icon (its Pickable's Icon) follows the pointer. With Show Model In Hand on, the tool's 3D model is also shown in front of the camera, to the right and low, in first person. In third person the model is in the avatar's preferred hand, whatever Show Model In Hand says, and the arm holds it.
- VR: the tool appears in the player's preferred hand, already held and locked: the grip does not let it go, the other hand and the other players cannot take it. The hand that holds it has no ray while it is held. The ray comes back while a menu is open (the radial menu, the inventory, the tablet).
The tool is held as the hand pivots of its Spawnable Object say (see Spawnable Object).
Using a tool
Use Mode decides what the use key does with the tool in hand:
| Use Mode | What happens |
|---|---|
| None (default) | The tool has no use of its own: holding it is all it does. In VR with the Inventory Placeholder the trigger still reaches the targets (see Item targets). Nothing is spent. This is how every tool before 2026.7 behaves. |
| Click | Each press of the use key is one use. |
| Hold | A use starts on the press and lasts until the release (a spray). On Use Ended is raised on the release. |
Each use spends one of the Pickable's Number Of Uses and raises its On Item Used; the last one raises On Item Expired. A hold counts as one use. The events are raised for the local player only.
A tool with 0 uses left stays in the hand and does nothing: its uses are not refilled.
Counted uses are spent on a target
A tool with a number of uses (1 or more) spends one only when the press reaches a target that takes the tool: the target the tool touches in VR, or the one under the pointer on desktop and mobile, that expects this tool and is not refusing items (see Item targets). A press on the wrong target, on a target that has been completed or locked, or on nothing, spends no use and raises no On Item Used. This way a key used again on a door already open does not lose a use, and a later task cannot become impossible.
A tool with unlimited uses (-1) raises On Item Used on every press, wherever it lands: reading it is up to you.
The press does nothing while the radial menu, the inventory or the tablet is open, while the pointer is on the inventory, or while the player is typing.
Keys
These keys belong to the application, on every environment. Do not bind them to something else in your scene:
| Radial menu | Next / previous tool | Use | |
|---|---|---|---|
| Desktop and web | Tab, or the hand slot | E / Q | Left click, or F |
| Mobile | The hand slot | Choose in the radial menu | Tap (Click) or press (Hold) |
| VR | B or Y (either hand), see below | Choose in the radial menu | Trigger of the hand that holds the tool |
In VR the B or Y button opens the inventory when the player has more than tools, and the radial menu directly when the tools are the only thing. The hand slot of the inventory opens the radial menu too. Your own Action on the Inventory Placeholder works besides these keys.
When your environment hides the tools (Set Alpha to 0, see Inventory Nodes), the keys neither open the radial menu nor switch tool. They are also ignored while the player types in a text field.
From a script
IVirtuademyGameplay.Current.Tools (namespace Virtuademy.Environments.ScriptingApi) tells a script when a tool is used, and where:
| Member | What it is |
|---|---|
ToolUseStarted | A use started: this player's or, in a multiplayer session, another player's. |
ToolUseEnded | The use ended: the release of a held use, at once after a single press. |
HeldToolModel | The held tool's 3D model in the avatar's hand, on desktop and mobile in third person. null in first person, when the tool shows no model, and in VR (use IPlayerApi.RightHand or LeftHand). It changes when the view changes between first and third person: read it when the effect starts, and while it lasts. |
Both events pass a ToolUse:
| Property | What it is |
|---|---|
ToolName | The tool's name (its Pickable's Item Name). |
IsLocal | true for this player's own use. |
Player | The name of the player using it. |
Aim | Where the use starts and where it points (its forward). For another player, a point at their avatar's right hand, turned where they aimed when the use started. Parent the effect to it, so it follows. |
An effect every player sees (a spray's jet) starts under Aim for every ToolUseStarted, and stops on ToolUseEnded. What the use does to the world (a target hit, a task completed) is done only when IsLocal is true, so it happens once.
using UnityEngine;
using Virtuademy.Environments.ScriptingApi;
public class SprayJet : MonoBehaviour
{
[SerializeField] private GameObject jetPrefab;
private GameObject jet;
private void OnEnable()
{
if (IVirtuademyGameplay.IsAvailable)
{
IVirtuademyGameplay.Current.Tools.ToolUseStarted += OnUseStarted;
IVirtuademyGameplay.Current.Tools.ToolUseEnded += OnUseEnded;
}
}
private void OnDisable()
{
if (IVirtuademyGameplay.IsAvailable)
{
IVirtuademyGameplay.Current.Tools.ToolUseStarted -= OnUseStarted;
IVirtuademyGameplay.Current.Tools.ToolUseEnded -= OnUseEnded;
}
}
private void OnUseStarted(ToolUse use)
{
if (use.ToolName != "Spray")
{
return;
}
// One jet at a time in this example: a jet per player needs a list.
jet = Instantiate(jetPrefab, use.Aim);
jet.transform.localPosition = Vector3.zero;
jet.transform.localRotation = Quaternion.identity;
}
private void OnUseEnded(ToolUse use)
{
if (use.ToolName == "Spray" && jet != null)
{
Destroy(jet);
}
}
}
There is no node for these two events. The Set Alpha node and the node that adds a pickable to the inventory are in Inventory Nodes.
For the other rules of scripts (what is allowed, how to handle IsAvailable), see Writing scripts.
Multiplayer
- The inventory and the radial menu are each player's own. Picked Tools Shared and Pickup Sharing decide whose menu a picked tool goes to.
- The tool a player holds is seen by the other players in that player's hand. On desktop and mobile the application builds the tool's model in the avatar's hand for them, with the arm holding it, even when Show Model In Hand is off; in VR the tool in the hand is a networked object, and the other players cannot take it.
- A use is seen by everyone through
ToolUseStartedandToolUseEnded. The Pickable's events and On Use Ended are raised for the local player only: nothing is sent to the others.
The earlier Tool Inventory Placeholder
The Tool Inventory Placeholder of earlier releases still works, with the same tools: the Tool Item Placeholder fields are the same. Its limits against the Inventory Placeholder are those listed in Inventory: a picked tool goes to the radial menu and is chosen there, and in VR the targets react as soon as the tool touches them.
Known limits
- The held tool in other players' view. On desktop and mobile each client builds the model in the other player's avatar hand from the tool that player holds (carried by a player property, so a late joiner gets it), and bends the arm to hold it. The code is there, but it was not verified at runtime in a multiplayer session at the time of writing: if the model does not appear in another player's hand, that is this limit. In VR the tool in the hand is a networked object, which other players see without it.
- First person. The model shown in front of the camera (Show Model In Hand) is a fixed place to the right and low; its place cannot be set.
- Shared tools. The tool a player picked up reaches the others by looking up its object in their scene: where that object is gone, or for a player who joins later, the tool is not added (see Inventory).
- VR layout. The radial menu and the inventory in VR are still being tuned.