MAP: API
Controlling your characters at runtime is simple. The primary component you will interact with is the MeshAnimator.
The MeshAnimator Component
This component is the „brain“ of an individual character. You will add it to your character prefabs (or have the baker do it for you). Its main purpose is to hold the list of available animations and manage the character’s internal animation state.
- LOD Levels: Here you configure which
MeshAnimationassets to use for each level of detail. You must create different lists of animations (e.g., high-quality for LOD0, low-quality for LOD1) and assign them here.
Public Methods
You can get a reference to the MeshAnimator and call these methods from your own controller scripts.
// Get the animator component
MeshAnimator myAnimator = GetComponent<MeshAnimator>();
public void Play(string clipName)- Plays an animation based on its string name (e.g., „Run“). This is the most common way to change animations.
myAnimator.Play("Run");
public void Play(MeshAnimation clipToPlay)- Plays an animation from a direct asset reference. This is slightly more performant as it avoids a string lookup.
public MeshAnimation attackClip;myAnimator.Play(attackClip);
public void Stop()- Stops the current animation.
public bool GetBoneTransform(string boneName, out Vector3 position, out Quaternion rotation)- Gets the current world-space position and rotation of a baked bone. Used by the
AttachmentPointsystem.
- Gets the current world-space position and rotation of a baked bone. Used by the
- public MeshAnimation GetCurrentAnimation()
- Gets the current played MeshAnimation