Skip to content

Key

Names a stored value, a state, a tag, a signal or a pool. A key is local to the object that defines it, or a shared Key asset when unrelated objects must agree on it.

Namespace: Jungle.Data Types: SmartKey (the field you fill in), Key (the shared asset, a JungleScriptableObject)

Overview

Every key field in Jungle works the same way. By default a key is local: you type a name right where the key is defined, for example on a Data Storage entry or a State Machine state, and nothing else is needed. Fields that use the key show a ▾ listing the keys defined nearby, so you pick a key instead of retyping it.

Switch a key to Asset when objects that know nothing about each other must share it: every item a hand can pick up, a tag checked by a slot across the scene, a signal sent from one prefab to another. The + button turns a local key into a Key asset in place, and everything that already used the local key keeps working.

A key can also be read from a source while the game runs, for example the first tag of the object a spawn is about. Pick it from the same button: From Source. Fields that define a key (a storage entry, a state, a tag) only offer Local and Asset.

Keys are matched by a stable id, never by name. Renaming a key, local or asset, breaks nothing, and saved games stay valid.

Where keys are used:

  • DataStorage stores and retrieves values by key.
  • Inventory identifies item entries and slots by key.
  • StateMachine names each of its states with a key, and transitions pick their target state from the list.
  • Tagger labels a GameObject with keys, matched by the Tag filter.
  • Signals are keys: a Reactor receives them and a LocalSignalTransmitter routes them.

When to use an asset

The key is... Use
Defined and read on the same object, prefab or state machine Local
Read from a storage only known at play time (the dragged object, an inventory item) Asset
A tag checked by filters on other objects Asset
A signal sent between unrelated objects Asset

The Inspector warns when a local key cannot match anything, for example when the storage it reads is only known at play time.

Key asset properties

Property Type Description
description string Optional notes for designers (TextArea).

See Also