Component:DynamicReferenceVariableDriver

From Resonite Wiki
Revision as of 16:36, 19 March 2024 by 989onan (talk | contribs) (add a ton of info)

Dynamic Reference Variable Driver is a component that can drive a SyncRef`1 (Reference Holder) to the value assigned to a dynamic variable with the name VariableName</code. if the specified variable cannot be found, the value will revert to DefaultTarget how this works is explained on Dynamic Variables page.

Component image 
Dynamic Reference Variable Driver`1 component as seen in the Scene Inspector


Fields

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.
VariableName String The Variable name that will be used to link this component's refrenced value to the Dynamic Variables System.
Target SyncRef<IWorldElement>
DefaultTarget IWorldElement The value/reference to revert to when this component cannot find the specified VariableName dynamic variable.

Usage

Examples

This component can be used as a way of abusing how dynamic variables are read by making this component with a slot type. Since this component reads from the slot it is on, this component can drive the parent field of another slot. Using this in tandem allows for interesting behavior. For example: Start with an avatar that has a slot on it's head, with a DynamicReferenceVariable<Slot> pointing to it with the VariableName field having "User/Hat" in it. then have an item like a hat stand with the stand slot having a DynamicReferenceVariableDriver<Slot> with a VariableName with "User/Hat" on it. the DefaultTarget would be the slot the component is on, which is the hat stand. The hat stand would a hat parented to it. the hat would have it's parent field driven by the component on the hat stand. Since the hat stand would be sitting in a world, the hat will stay on the stand, since it can't find the variable, "User/Hat". the second a user picks the stand up with a slot variable that is named "User/Hat", the hat will move from the stand to the slot specified by the variable on that user. Keep in mind, that the hat in this scenario has nothing to do with how the variable is read, but rather the stand does. When the stand unparents from the user, the slot sampling the variable space which is the stand can no longer find the variable. What then happens is the field the DynamicReferenceVariableDriver<Slot> is driving will revert to DefaultTarget which is the stand slot, making it move back to the stand.

This also allows for the slot that moves (also known as the hat) to sample values too, allowing for even more complex reading and interaction (EX: the hat moves to the user's head and changes color to the user's color)

Related Components