Table of Contents

AnimationUtility

AnimationUtility is a static utility class to be used with all animation types. The full API docs can be found here.

Raw Positions & Deltas

One of TMPAnimator's settings is a toggle that decides whether animations should be scaled or not (see TMPAnimator Settings).
In some cases, you will want to ignore this scaling in your animation though. For example, the built-in spread animation sets the individual vertices of the character to the center point of the character, to make it invisible at first and then over time spread out from the center point to the original vertex positions. If this was scaled, then the vertices would in many cases move either not enough, or too far, to make the character invisible.
These methods allow you to get and set positions and deltas that ignore the scaling of the animator:

Getters

Vector3 GetRawVertex(int index, Vector3 position, CharData cData, ref IAnimationContext ctx) - Calculate the raw version of the passed in vertex position, i.e. the one that will ignore the animator's scaling.

Vector3 GetRawPosition(Vector3 position, CharData cData, ref IAnimationContext ctx) - Calculate the raw version of the passed in character position, i.e. the one that will ignore the animator's scaling.

Vector3 GetRawDelta(Vector3 delta, CharData cData, ref IAnimationContext ctx) - Calculate the raw version of the passed in delta, i.e. the one that will ignore the animator's scaling.

Setters

void SetVertexRaw(int index, Vector3 position, CharData cData, IAnimationContext ctx) - Set the raw position of the vertex at the given index. This position will ignore the animator's scaling.

void SetPositionRaw(Vector3 position, CharData cData, IAnimationContext ctx) - Set the raw position of the character. This position will ignore the animator's scaling.

void AddVertexDeltaRaw(int index, Vector3 delta, CharData cData, IAnimationContext ctx) - Add a raw delta to the vertex at the given index. This delta will ignore the animator's scaling.

void AddPositionDeltaRaw(Vector3 delta, CharData cData, IAnimationContext ctx) - Add a raw delta to the position of the character. This delta will ignore the animator's scaling.

AnchorToPosition

Given a Vector2 that represents an anchor (see ParameterTypes), you can calculate the actual position on the character using the Vector2 AnchorToPosition(Vector2 anchor, CharData cData) method.

GetValue

A simple wrapper method that allows you to evaluate an AnimationCurve in any WrapMode.

Wave Utility

The AnimationUtility class contains a Wave type; for more information about it as well as the WaveOffsetType enum, see the next section.

These are the utility methods for the Wave type:

Converting functions

There are a few simple, general converting functions (that are not specific to the Wave type, but to waves in general):

float FrequencyToPeriod(float frequency) - Get the period of a wave from its frequency
float PeriodToFrequency(float period) - Get the frequency of a wave from its period
float WaveLengthVelocityToFrequency(float wavelength, float wavevelocity) - Get the frequency of a wave from its wavelength and velocity
float WaveLengthFrequencyToVelocity(float wavelength, float frequency) - Get the velocity of a wave from its wavelength and frequency
float WaveVelocityFrequencyToLength(float wavevelocity, float frequency) - Get the wavelength of a wave from its velocity and frequency

GetWaveOffset

When evaluating a Wave, you have to pass in an offset, which is dependent on the current character you are animating as well as the WaveOffsetType you are using; the float GetWaveOffset(CharData cData, IAnimationContext ctx, WaveOffsetType type) calculates the correct offset for you.