playMaker

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

Numster

  • Playmaker Newbie
  • *
  • Posts: 9
Pooling system and NavMesh
« on: September 04, 2019, 10: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: 7614
    • jinxtergames
Re: Pooling system and NavMesh
« Reply #1 on: September 04, 2019, 05: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: 21
Re: Pooling system and NavMesh
« Reply #2 on: November 22, 2019, 11: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?

eotiti

  • Junior Playmaker
  • **
  • Posts: 65
Re: Pooling system and NavMesh
« Reply #3 on: June 02, 2023, 05:27:33 AM »
Thank you !