So where to begin.
In my project, I have a dog npc. It's supposed to follow my player.
Using 'set agent destination as game object', destination is my player model. Problem #1, the dog moves independent of the dog's animator animation. This was "fixed"? with this script.// LocomotionSimpleAgent.cs
using UnityEngine;
[RequireComponent (typeof (NavMeshAgent))]
[RequireComponent (typeof (Animator))]
public class NavMeshAutoOff : MonoBehaviour {
Animator anim;
NavMeshAgent agent;
Vector2 smoothDeltaPosition = Vector2.zero;
Vector2 velocity = Vector2.zero;
void Start ()
{
anim = GetComponent<Animator> ();
agent = GetComponent<NavMeshAgent> ();
// Don’t update position automatically
agent.updatePosition = false;
}
}
Problem #2: the dog spins around, back and forth. If I go into the scene view while my project is running I can see the navmesh cylinder on my player character, moving continuously side to side. Coincidence? This happens with no FSM's or code on the dog.
Problem #3, probably because of problem #2, the dog often turns and runs in the opposite direction, away from the player.
So if this is something that happens normally when using NavMesh (I'm hoping it is), then maybe someone could shed some light on the problem? If it's not normal I'm not really sure how to better explain what's going on, maybe a video? I just really need some help.