Dowload as PDF

1.5. Curves

Common Info

Curves serve only one goal: to superpose given value to a given state for the duration of the entire state. Just as standard curves in Unity, which could be used in animation clips. Unlike them, Curves in MecanimCallbacker are more flexible and complex, allowing you to solve more complex tasks.

Every Curve by itself contains several curves (called SubCurve), each of which is installed for a given state. This lets you attach a curve to several states at once. For every SubCurve you can also install several Modifiers. These are elements that change the value of the curve depending on their settings. All Modifiers are applied consequetively, changing the value and passing it onto the next. They work the following way: every Modifier has two states: first one contains data, that will replace previously calculated value, second contans the amount of influence of the first curve on the calculated value.

Modifiers have several types:

  1. Parameter – uses float parameter from AnimatorController to calculate the amount of influence. This parameter points at which point the curve of influence amount is going to be requested.
  2. Transition from this – works in the case if AnimatorController is in the state of transition from the state, to which this SubCurve is attached to. If this is not the case, it's added automatically with linear interpolation.
  3. Transition to this– works in the case if AnimatorController is in the state of transition to the state, to which this SubCurve is attached to. If this is not the case, it's added automatically with linear interpolation.

They also have several types of work function:

  1. Override – Modificator replaces the previously calculated value.
  2. Multiply – Modificator is multiplied with previously calculated value.
  3. Additive – Modificator is added to previously calculated value.
  4. Min – minimal value between Modificator and previously calculated value is chosen.
  5. Max – maximal value between Modificator and previously calculated value is chosen.

Because several layers can be active at once, and hence the curve can be calculated based on several active SubCurves, a setting exists as to how to calculate the final value between layers. For every layer, just as with Modificators, you can set up the curve of influence (depends on layer weight) and calculation mode. Just as with Modificators, calculations occur consequitively.

Calculation of the Curve happens following way:

  1. All active at that moment SubCurves are collected.
  2. For each of them, values are calculated consequitevely.
    • For every Modifier, values are consequently calculated without the curve of influence. For example Multiply is calculated as: candidateValue = modifierValue * originalValue.
    • Then, based on the value gotten from parameter or Transition normalized time (in the case of Transition to/from this) we get the amount of influence from corresponding curve.
    • Original value is replaced to a blend of itself and Modificator value as: newValue = lerp(candidateValue, originalValue, interpolationValue).
  3. In the case several of them are in one layer – they are added (possible only in the case of transition, and hence in one layer you can only have maximum of two SubCurve). In the case SubCurve are located in separate layers, their values are calculated analagous to mechanics of Modifier.

Also, every curve can be automatically attached to parameter from AnimatorController. System will automatically update this parameter every frame according to the current value of the curve.

To get the value of the curve you can use the following two attributes.

  • BaseValue – returns value without applying Modifiers.
  • Value – returns value after applying all Modifiers.

Editor

  1. Layers blending modes – by-layer setting rules for mixing SubCurves. For every layer you can set its own rule, its own curve, as well as copy the rule from AnimatorController.
  2. Subcurves – list of curves based on which value is calculated.
    • Value – curve of influence. Value is calculated based on the normalized time state, to which this Subcurve is attached.
    • State – selection of the observed state, it's possible to preview the state by manual rewinding.
    • Modifiers – list of Modifiers of this Subcurve.
      • Value – curve of influence. Value is calculated based on the normalized time state, to which this Subcurve is attached.
      • Interpolation – curve of influence. Calculated based on Parameter or Transition normalized time.
      • Modifier mode – work function type of this modifier.
      • Modifier type – based on what to calculate the value of the curve of influence.
      • Animation parameter – parameter, based on which value of the curve of influence is calculated, in the case if ModifierType is set to Parameter.
Yes No
0 of 0 users found this section helpful
Suggest Edit