πŸƒLegacy vs. Modern Animation System

Understanding the difference between the two systems, and which might be the right one for you.

Intro to the Animation Systems

Legacy Animation System

The legacy animation system uses Unity's Animation component and Anything World's LegacyAnimationController component which blends between the different animation clips depending on parameters and function calls by the developer. It is primarily used when an object is being created at runtime and requires a transition between multiple animations.

Modern Animation System

The modern animation system uses Unity's own Animator component. This solution serializes all of the animation components and uses an Animator Override Controller to structure the transition links and parameters, which come together to make a fully structure animator. This system cannot be used at runtime, and requires you to have created the override controller in editor mode.

Pros & Cons

Legacy Animation System

ProsCons

Can be created both in Editor Mode and Play Mode

Is not directly compatible with the traditional animator

Simple to transition between different states

More rigid, as the legacy animation controllers strictly follow the animation state transitions set up on the object being loaded

Modern Animation System

ProsCons

Naturally integrates into the already existing systems in Unity

Can only be created in Editor Mode

Can be modified after creation through the created Animator Controller

Requires serialization, which could increase application build size

Using the systems

Legacy Animation System

To use the legacy animation system in editor, you can pass LegacyAnimatorInEditorOption(true) into your AnythingMaker.Make() call as a RequestParameter. Doing so tells the Anything World system to use the legacy animation system rather than the modern animation system. At runtime, the system will automatically default to creating an object using the legacy animator.

A created object, depending on its typing will come with a different legacy animation controller. Most animals by default are created with the RunWalkIdleController, whereas flying birds are created with the FlyingAnimationController.

Example

using UnityEngine;
using AnythingWorld.Animation;

public class ExampleClass : MonoBehaviour
{
    public float speed = 0.0167f;
    private float velocity;

    private GameObject createdGameObject;
    private RunWalkIdleController controller;

    public void Start()
    {
        createdGameObject = AnythingMaker.Make("Cat", RequestParameter.UseLegacyAnimatorInEditor(true));
    }

    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.W)) velocity += speed;
        if (Input.GetKeyDown(KeyCode.S)) velocity -= speed;
        velocity = Mathf.Clamp(velocity, 0, speed * 2);

        if (controller == null)
        {
            controller = createdGameObject.GetComponentInChildren<RunWalkIdleController>();
        }
        else
        {
            controller.walkThreshold = 0;
            controller.runThreshold = speed;
            createdGameObject.transform.Translate(0, 0, velocity);
            controller.BlendAnimationOnSpeed(velocity);
        }
    }
}

Modern Animation System

Anything World uses the modern animation system by default for any objects that are created in editor. As this system uses the built-in Unity animator, you can use their scripting API to modify and read from the controller created.

Last updated