playMaker

Author Topic: Navmesh - so confused  (Read 1963 times)

everycolorfades

  • Playmaker Newbie
  • *
  • Posts: 20
Navmesh - so confused
« on: August 07, 2016, 04:56:26 PM »
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.
Code: [Select]
// 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.

cwmanley

  • Full Member
  • ***
  • Posts: 107
Re: Navmesh - so confused
« Reply #1 on: August 07, 2016, 05:15:06 PM »
Hello,

This might help?

Survival Shooter Tutorial Creating Enemy

http://unity3d.com/learn/tutorials/projects/survival-shooter/enemy-one?playlist=17144

everycolorfades

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Navmesh - so confused
« Reply #2 on: August 07, 2016, 06:50:25 PM »
This might help?
Wow, I was setting some things up all wrong it seems. It looks better already, thanks!