playMaker

Author Topic: Navmesh help  (Read 2282 times)

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Navmesh help
« on: September 23, 2013, 12:26:42 PM »
Hi,
If I have a basic NavMesh with a NPC with a Animator.Follow FSM, how do I get the NPC to use the NavMesh? Because I can get the NPC to follow the player, but it runs into walls etc, so I'm guessing it doesnt use the NavMesh.
If I delete the Animator.Follow FSM, and use a simple script:

{
   public Transform m_Player;

void Update ()
   {
   
      GetComponent<NavMeshAgent>().destination = m_Player.position;
   }
}

Then the NavMesh works perfect, but it doesnt use the Animator.
Am I missing something?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Navmesh help
« Reply #1 on: September 24, 2013, 06:14:16 AM »
Hi,

 have you studied the mecanim exmaple using navmesh?

https://hutonggames.fogbugz.com/default.asp?W1031

 get this demo:  PlayMakerAnimatorWithDemosPro.unitypackage UNITY PRO ONLY

 bye

Jean

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: Navmesh help
« Reply #2 on: September 24, 2013, 07:20:38 AM »
Yes I've looked at that thanks, but how do I set the NPC destination to the player?
If I Set Property > destination, from there you get Vector3, x, y, z.  So, from the NavMesh demo, the destination is set from a Vector3 by a mouse click,  but I need the destination set from the position of my player.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Navmesh help
« Reply #3 on: September 25, 2013, 01:57:38 AM »
Hi,

 You are very close.

 Instead of injecting the mouse position, simply inject the game object itself.

So in the state "Set agent destination", in action "Set property" you inject the game position, tjhat's all.

 You can get the gameobject position using the action "get position", put that just before the "set property" and save the gameobject position in the vector3 "destination"

Yes?

Bye,

 Jean