Component:ValueDriver: Difference between revisions

From Resonite Wiki
add info
overhaul
 
Line 1: Line 1:
{{Infobox Component
{{Infobox Component
|Image=ValueDriver`1Component.png
|Image=ValueDriver`1Component.png
|Name=Value Driver`1
|Name=ValueDriver<T>
}}
}}
{{stub}}
Makes one <code>DriveTarget</code>'s value be set to <code>ValueSource</code> value every game tick.


== Usage ==
The '''ValueDriver&lt;T&gt;''' component continuously copies the value of the source [[Type:IValue`1|IValue]] to the target [[Type:IField|field]] every [[update]]. The source and target types must be [[value types]].
 
== Fields ==
 
{{Table ComponentFields
{{Table ComponentFields
|ValueSource|'''[[Type:IValue`1|IValue`1]]&lt;T&gt;'''|TypeAdv0=true| The value field to get a value from.
|ValueSource|'''[[Type:IValue`1|IValue`1]]&lt;T&gt;'''|TypeAdv0=true| The value field to get a value from.
Line 12: Line 13:
}}
}}


== Behavior ==
== Usage ==
 
This component ensures that the value in the <code>DriveTarget</code> is equal to the value in the <code>ValueSource</code> field. To do this, it [[drives]] the <code>DriveTarget</code> field to give it exclusive access to the value, then it starts writing the value from the <code>ValueSource</code> field to the target field every update.
 
This is distinct from [[Component:ValueCopy|ValueCopy]], as it allows sourcing from [[Type:IValue`1|IValue]] elements instead of just [[Type:IField`1|IField]] elements. It also does not have any <code>WriteBack</code> meachanism of any kind. Generally, ValueCopy should be used whenever possible, as it only updates the target field whenever the source field changes instead of every update.


== Examples ==
== See also ==
This is useful for a lightweight version of [[Component:ValueCopy|Value Copy]] to make one value equal to another, when write back isn't needed.


== See Also ==
* [[Component:ValueCopy]]
* [[Component:ValueCopy|Value Copy]]
* [[Component:ValueMultiDriver]] to form this relation to multiple target fields.


[[Category:Components:Relations{{#translation:}}|Value Driver`1]]
[[Category:Components:Relations{{#translation:}}|Value Driver`1]]
[[Category:Components{{#translation:}}|Value Driver`1]]
[[Category:Components{{#translation:}}|Value Driver`1]]
[[Category:Generic Components{{#translation:}}|Value Driver`1]]
[[Category:Generic Components{{#translation:}}|Value Driver`1]]

Latest revision as of 15:08, 14 September 2025

Component image 
ValueDriver<T> component as seen in the Scene Inspector

The ValueDriver<T> component continuously copies the value of the source IValue to the target field every update. The source and target types must be value types.

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. Some components stop their functionality when this field is disabled, but some don't.
ValueSource IValue`1<T> The value field to get a value from.
DriveTarget field drive of T The value field to set to the value of ValueSource.

Usage

This component ensures that the value in the DriveTarget is equal to the value in the ValueSource field. To do this, it drives the DriveTarget field to give it exclusive access to the value, then it starts writing the value from the ValueSource field to the target field every update.

This is distinct from ValueCopy, as it allows sourcing from IValue elements instead of just IField elements. It also does not have any WriteBack meachanism of any kind. Generally, ValueCopy should be used whenever possible, as it only updates the target field whenever the source field changes instead of every update.

See also