PlayMaker Help & Tips > PlayMaker Tips & Tricks

Pooling system and NavMesh

(1/1)

Numster:
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:
Hi.
Thanks for the tip!

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

Rebooter:
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:
Thank you !

Navigation

[0] Message Index

Go to full version