# OnAnimatorMove()

> Callback for processing animation movements for modifying root motion.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)

```csharp
public void OnAnimatorMove()
```

### Remarks

This callback will be invoked at each frame after the state machines and the animations have been evaluated, but before OnAnimatorIK. Additional Resources: [Root motion](/engine/6000.0/manual/animation-section/animation-mecanim/avatar-creationand-setup/root-motion.md).

### Examples

```csharp

// Attach this script to your character GameObject that has an Animator and optionally a Rigidbody.
// Enable "Apply Root Motion" on the Animator. Adjust rootMotionMultiplier to speed up or slow down root motion.

using UnityEngine;

[RequireComponent(typeof(Animator))]
public class RootMotionModifier : MonoBehaviour
{
    public float rootMotionMultiplier = 2.0f; // Scale the root motion

    private Animator animator;
    private Rigidbody rb;

    void Awake()
    {
        animator = GetComponent<Animator>();
        rb = GetComponent<Rigidbody>();
    }

    void OnAnimatorMove()
    {
        // Only modify root motion if we have a Rigidbody
        if (rb != null)
        {
            // Get the deltaPosition from the Animator
            Vector3 deltaPosition = animator.deltaPosition * rootMotionMultiplier;
            // Preserve vertical velocity (for example, gravity)
            Vector3 velocity = deltaPosition / Time.deltaTime;
            velocity.y = rb.velocity.y;
            rb.velocity = velocity;

            // Optionally apply root rotation
            rb.MoveRotation(rb.rotation * animator.deltaRotation);
        }
        else
        {
            // If no Rigidbody, just move the transform
            transform.position += animator.deltaPosition * rootMotionMultiplier;
            transform.rotation *= animator.deltaRotation;
        }
    }
}
```
