Getting Started

Introduction

Installation

Project Configuration

Testing in Your Sandbox

Samples & Examples

Core Concepts & Glossary

Package Types

Spaces & Space Templates

Custom Avatars

Custom Avatar Animations

Avatar Attachments

Custom Prefab Objects

Embedded Packages

Drivable Vehicles

Scene Setup

Testing In Unity vs Sandbox

Controlling the Camera

Custom Collision, Layers, and Tags

Audio Mixers and Groups

Key Differences from Standard Unity3D development

Economy

Quests and Rewards

Economy Overview

Monetization

Items

Consumable Items

Rewarding Items

Consumables.jpg

Consumable Items

A consumable item is any item that can be consumed from the user’s backpack in exchange for granting special effects on their avatar and experience. Some examples of what a consumable item can be (but not limited to):

After an item is consumed, it is removed from the user’s backpack. For now, only Basic Item types are allowed to be consumed.

<aside> ⚠️ Consumable items require knowledge of Visual Scripting to implement functionality in a Space package.

</aside>

<aside> 🚧 This is a new feature and under development. There will be more functionality and settings to tweak in the future, so stay tuned!

</aside>

Creating a Consumable Item

<aside> ✋ In order to create a consumable, you would first need to create a basic item for your world in Studio. If you’re unsure how to create a basic item, you can follow this guide on how to do so.

</aside>

Navigate to the settings of the item of your choice and scroll down until you see a toggle for Consumable under the backpack settings. Enabling this will give some basic functionality to consume the item, and reveal additional settings.

Untitled

Adding Consumable Functionality with Visual Scripting

In order to make the consumable actually do something, behavior will need to be defined within a Script Machine and Scripting Graph inside of a Space package’s scene.

Relevant scripting nodes that can help facilitate this are listed below:

Scripting Graph Examples

The images below show two examples of how consumable items can be implemented.

When consumed, the frozen pizza makes your avatar jump and adds extra upwards force immediately after.

When consumed, the frozen pizza makes your avatar jump and adds extra upwards force immediately after.

The frozen pizza consumable has no Duration set, so it only needs to listen to the On Backpack Item Consumed event for the pizza’s item ID. The On Consumable Item Duration Expired event will not be executed since the Duration was set to 0.

Untitled

The nocturnal pill example is a bit more complicated. The On Backpack Item Consumed event node is used as usual to activate the effect when it’s consumed. However, unlike the pizza example above, there is a Duration set for the item (in this case, 120 seconds). There needs to be an On Consumable Item Duration Expired event that needs to be listened for in order to deactivate the item’s effects after the Duration has elapsed. Alternatively, you can constantly poll the state with Get Consumable Item State but that can be slower and/or less convenient. The logic will work as long as the user doesn’t leave the space during the item’s Duration, but will fail to activate the effects if they re-join the space while the item is active. This is fixed by using Get Consumable Item State when the scene initializes, which will get the initial value and activate the effects automatically.

← Previous

Items

Next →

Rewarding Items