Component:DynamicVariableSpace
More actions

Introduction
The DynamicVariableSpace component is used to separate dynamic variables into namespaces. Since dynamic variables are, by default, created on the slot of the nearest parent DynamicVariableSpace, this component provides control over where the root of that space is, as well as part of the path name to be referenced when using a consumer of dynamic variables, such as DynamicValueVariableDriver`1. For more info see Dynamic Variables.
Fields
| Name | Type | Description |
|---|---|---|
persistent
|
Bool | Determines whether or not this item will be saved to the server. |
UpdateOrder
|
Int | Controls the order in which this component is updated. |
Enabled
|
Bool | Controls whether or not this component is enabled. Some components stop their functionality when this field is disabled, but some don't. |
SpaceName
|
String | The name of the space. Names are trimmed of leading and trailing spaces, and may only contain letters, digits, spaces and the characters -, . and _. A name with any other symbol or punctuation, including /, is not accepted, and the space is then left without a name.
|
OnlyDirectBinding
|
Bool | When enabled, variables won't be bound to this space unless they specify it by name: SpaceName/VariableName.
|
Usage
Add the component to the slot that should be the root of the space. Every dynamic variable on that slot or on any of its children belongs to the space, unless a closer space is found first. Give the space a SpaceName if variables need to address it by name, or if several spaces are nested and one has to be told apart from the others.
Behavior
Finding the space
A dynamic variable looks for its space by searching its own slot and then each parent in turn.
- A variable name without a space, such as
Color, binds to the nearest space that does not haveOnlyDirectBindingenabled. - A variable name with a space, such as
Gadget/Color, binds to the nearest space whoseSpaceNameisGadget, whether or not it hasOnlyDirectBindingenabled.
Changing SpaceName, or duplicating the slot, makes the variables look for their space again.
Sharing values
Within a space, all variables with the same name and the same type share one value. Writing to any of them changes all of them. A variable of a different type with the same name is a separate variable and does not share the value.
- Variables that store a value, such as a DynamicValueVariable, own the shared value. Components that only receive it, such as a DynamicValueVariableDriver or a DynamicVariableStatus, do not.
- The first storing variable to appear sets the value of the shared variable.
- A storing variable that joins later takes over the current shared value. If its
OverrideOnLinkoption is enabled, it instead writes its own value to all the others. - When the last storing variable of that name and type is removed, the shared value is gone. A DynamicValueVariableDriver that is still listening to that name then writes its own
DefaultValuefield into its target, instead of any value from the space. The same happens to a driver whose name finds no storing variable in the first place.
Examples
By default worlds have a DynamicVariableSpace named "World", and users have a DynamicVariableSpace named "User".
A prop that has its own space named Gadget on its root keeps its variables separate from everything else in the world. A control inside the prop can read a variable Color from that space, while a control elsewhere that wants the same value has to use the full path Gadget/Color, and can only reach it if it is under the prop's root.
ProtoFlux nodes are the exception to needing to be parented under the space. The Read DynVar and Write DynVar nodes take a slot and a path, and look for the space starting from that slot, with the same rules as above. A graph can therefore be anywhere in the world and still reach a space, as long as it is given a reference to a slot inside it. If no slot is connected, the node uses its own slot.
Performance
When a slot gets a new parent, every dynamic variable on it and on its children searches for its space again. The search reads the components on the variable's own slot, in the order they were added, until it finds a space, and then continues with the parent.
The cost of a search is the number of components in front of the space. With one variable per slot and the space one slot up, that is one. With thousands of variables on one slot and the space on a parent or after them, every variable walks past all the others, so moving the slot costs roughly the variable count squared.
Adding the DynamicVariableSpace as the first component of the slot that holds the variables ends every search at once, however many variables follow. This matters for objects that change parent often, such as an item that is picked up and put down. It also speeds up creating the variables, which runs the same search.
The table shows the median time one move takes (the worst frame minus the median frame of the same measurement) for each placement of the space, over 5 fresh runs of 3 moves each, measured on a desktop client running Resonite 2026.11.16.1330.
| Placement of the space | 100 variables | 10,000 variables |
|---|---|---|
| One slot per variable, space one slot up | 0.1 ms | 1.8 ms |
| All variables on one slot, space one slot up | 0.1 ms | 411 ms |
| All variables on one slot, space on that slot as its first component | 0.1 ms | 1.2 ms |
| All variables on one slot, space on that slot as its last component | 0.1 ms | 397 ms |