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;
}
}