The agent doesn't start from a specified position

I have an issue:

Hello, I’m using the last version of A* Pathfinding Project and I’m having an issue.

I created a pool of prefabs where each one contains a FollowerEntity script.

The idea is that NPCs request a FollowerEntity agent from the pool when they need one, and return it to the pool once they’re done using it.

These are the steps:

  1. I request an agent from the stack,

  2. I move the Agent to the NPC’s position,

  3. I assign it the destination position,

  4. the NPC copies the agent’s position until it reaches the destination.

  5. Return the agent to the stack when the destination is reached.

The problem is at the starts; the agent doesn’t begin at the NPC’s position but rather from some random position nearby.

Note: that the NPC is on the navmesh

Any idea why this happens?

Thanks

Hi

Do you enable the agent component (or gameobject) before it is moved?
The FollowerEntity will try to keep the agent on the navmesh, and will prevent it from being moved too much while it is active.

If you move it while the agent is disabled, this won’t happen though.
If you really need to move it while the agent is enabled, use the followerEntity.Teleport method.

Thank you very much for your prompt response — using Teleport resolved the issue.
One more question: when managing a pool of unused agents, which approach is more efficient

  1. disabling them with _FollowerEntity.enabled = false;
    or
  2. using _FollowerEntity.isStopped = true;
    Thank you in advance.

Disabling the component entirely will use less cpu power.