# Legacy vs. Modern Animation System

## 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.&#x20;

### 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

| Pros                                             | Cons                                                                                                                              |
| ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| 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

| Pros                                                                   | Cons                                                                |
| ---------------------------------------------------------------------- | ------------------------------------------------------------------- |
| 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)](https://anything-world.gitbook.io/anything-world/unity/documentation/anythingworld-api/requestparameter/legacyanimatorineditoroption) into your [AnythingMaker.Make()](https://anything-world.gitbook.io/anything-world/unity/documentation/anythingworld-api/anythingmaker/make) call as a [RequestParameter](https://anything-world.gitbook.io/anything-world/unity/documentation/anythingworld-api/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](https://anything-world.gitbook.io/anything-world/unity/documentation/anythingworld-api/animation/legacyanimationcontroller/movementjumplegacycontroller), whereas flying birds are created with the [FlyingAnimationController](https://anything-world.gitbook.io/anything-world/unity/documentation/anythingworld-api/animation/legacyanimationcontroller/flyinganimationcontroller).

#### Example

```csharp
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](https://docs.unity3d.com/ScriptReference/Animator.html) to modify and read from the controller created.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://anything-world.gitbook.io/anything-world/unity/legacy-vs.-modern-animation-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
