Root motion handle rotation

Hey guys,

I’m currently working on navigation fully controlled by root motion (animation-driven locomotion) for a project, and I have managed to set the velocity of the agent to be the root motion, but how do I enable root motion animation to control the rotation of the agent?

Thanks!

This is what i have so far:

using UnityEngine;
using System.Collections;

public class MoveToTarget : MonoBehaviour {

    private NavMeshAgent agent;
    private Animator anim;

    void Start () {

        agent = GetComponent<NavMeshAgent>();
        anim = GetComponent<Animator> ();

        anim.applyRootMotion = true;
        agent.updatePosition = true;
        agent.updateRotation = true;
    }
   
    // Update is called once per frame
    void Update () {

        if(GameObject.Find("Pickup(Clone)") != null)
            agent.destination = GameObject.Find("Pickup(Clone)").transform.position;
    }

    void OnAnimatorMove () {

        agent.velocity = anim.deltaPosition / Time.deltaTime;
    }
}

I’m looking for something similar to:
agent.velocity= anim.deltaPosition/Time.deltaTime;
but for rotation…

Sorry, it was the wrong link.

float angleInDegrees;
Vector3 rotationAxis;
anim.deltaRotation.ToAngleAxis(out angleInDegrees, out rotationAxis);
Vector3 angularDisplacement = rotationAxis * angleInDegrees * Mathf.Deg2Rad;  
agent.velocity= angularDisplacement / Time.deltaTime;
1 Like

Late reply, sorry. Thanks a lot man!