Variables Methods
v4.0
Each GameItemObject
has a List<ItemObjectVariable>
which contains all the variables, and the current values.
When the Value
changes, if variableAttributes
are in use, then the system will automatically check to see if the existing GameItemAttribute
needs to be updated. If so, the system will remove all GameItemAttributes
of the ObjectType
from the list, and add the new one based on the current RangeValue
.
SetStatsDirt()
will then be called on the GameItemObject
, triggering stats to recompute their values.
Methods
Get Value & RangeValue
Example
You can use the value of durability to modify the "price" of a GameItemObject
.
Add Value
Use the AddValue()
method to add value to the Variable. Add a negative value to subtract. The final Value will be clamped between Min
and Max
, and RangeValue
will be updated.
Returns the RangeValue
of the Variable.
Set Value
Use the SetValue()
method to set the value to a specific amount. Add a negative value to subtract. The final Value will be clamped between Min
and Max
, and RangeValue
will be updated.
Returns the RangeValue
of the Variable.
You can change the values of Min
and Max
at runtime! While they will always start at the values set in the ItemObject
scriptable object, you can modify them later for even more game mechanic opportunities.
Set to a specific RangeValue
RangeValue
RangeValue
is always between 0f
and 1f
, between the Min
and Max
values and modified by the curve, if in use. Rather than setting the specific Value
, you can opt to set a RangeValue
, and the Value
will be computed based on that.
Returns the Value
of the Variable.
Last updated