Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Character (humanoid) move speed differs from source animation

Discussion in 'Animation' started by Nathanieljla, Sep 25, 2022.

  1. Nathanieljla


    Apr 18, 2014
    I've been attempting to work around a speed issue in Unity, which led me to this simple to test, yet confusing issue. I have a walk animation that travels at 1.196 m/s. If I monitor the travel speed in game, I've discovered it's moving at 1.28 m/s. I would expect to see foot sliding at this point, but the feet look rock solid. If I attempt to force the movement vector magnitude to the correct speed, then the feet slip. I can't explain/understand how this is happening. If the animation was mapped from one character to another, then I could see it being some character height compensation, but it's the same character in the rig and animation. I'm totally lost.


    Here's my code for how I'm testing this
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    5. public class Move : MonoBehaviour
    6. {
    7.     public Animator animator;
    8.     public CharacterController characterController;
    9.     public bool useTargetParam = false;
    10.     private Vector3 _rootMotionPositionDelta =;
    11.     private Quaternion _rootMotionRotationDelta = Quaternion.identity;
    12.     private float _smoothedRootSpeed = 0f;
    13.     private float _targetSpeed = 0f;
    14.     private float _outputSpeed = 0f;
    17.     // Update is called once per frame
    18.     void Update()
    19.     {
    20.         _smoothedRootSpeed = Mathf.Lerp(_smoothedRootSpeed, _rootMotionPositionDelta.magnitude / Time.deltaTime, 1 - Mathf.Exp(-2 * Time.deltaTime));
    21.         animator.SetFloat("Root Speed", _smoothedRootSpeed);
    23.         Vector3 movement = !useTargetParam ? _rootMotionPositionDelta : _rootMotionPositionDelta.normalized * (_targetSpeed);
    24.         characterController.Move(movement);
    26.         _outputSpeed = Mathf.Lerp(_outputSpeed, movement.magnitude / Time.deltaTime, 1 - Mathf.Exp(-2 * Time.deltaTime));
    27.         animator.SetFloat("Output Speed", _outputSpeed);
    28.         Reset();
    29.     }
    31.     public void Reset()
    32.     {
    33.         //// Reset root motion deltas
    34.         _rootMotionPositionDelta =;
    35.         _rootMotionRotationDelta = Quaternion.identity;
    36.         _targetSpeed = 0f;
    37.     }
    40.     //When this callback exists, the animator component root controller option will be overridden with a statement of
    41.     //"Handled by script".  How cool is that!
    42.     private void OnAnimatorMove()
    43.     {
    44.         _rootMotionPositionDelta += animator.deltaPosition;
    45.         _rootMotionRotationDelta = animator.deltaRotation * _rootMotionRotationDelta;
    46.         _targetSpeed += animator.GetFloat("Target Speed") * Time.deltaTime;
    47.     }
    48. }
  2. Nathanieljla


    Apr 18, 2014
    I decided to try and rule out the humanoid character as being part of the issue and it does indeed look to be part of the issue. When an animation is marked as generic the reported speed matches Maya. When I switch the rig to a humanoid it reports the animation as slower, but it still moves through space at the proper speed. Why is the humanoid reporting a different speed then playing another at runtime?