playMaker

Author Topic: Pooling system and NavMesh  (Read 816 times)

Numster

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Pooling system and NavMesh
« on: September 04, 2019, 07:07:10 AM »
Hi,

I had to face to an issue there is a few days and I would share the solution here.

Issue: When you use a pooler to spawn and respawn a prefab with a navMesh agent and the "NavMesh agent move to" action, that works once, and only once. No problem for the first spawn, but, when the prefab respawn, he can't move...

Fix: Disable the navMesh agent on the prefab and enble it at start. Don't use the "navmesh agent move to" in this case, but drag the navMesh agent in the state and click on "Script control" and "Call method", then use the setDirection (bool) to configure the agent's destination and active the everyframe bool.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4613
    • View Profile
    • jinxtergames
Re: Pooling system and NavMesh
« Reply #1 on: September 04, 2019, 02:01:51 PM »
Hi.
Thanks for the tip!

Indeed when pooling you actually need to 'Reset' many things Before 'Despawning' (and/or set certain values @ start)

Rebooter

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: Pooling system and NavMesh
« Reply #2 on: November 22, 2019, 09:33:47 PM »
Why is it that you can't use 'NavMesh agent move to' in that situation? I'm using a custom version of it that uses an FsmObject field to store the NavMeshAgent (set at design time) rather than using GetComponent to get it from the owning object.

I haven't trying pooling yet, but will need to when I get other things finished. This could be a major problem going forward, so what is it about that action that prevents it from working after being respawned as part of a prefab?