I am setting a destination to a Tree. Both my agent and tree have trigger colliders and no rigidbodies, so they can pass through each other. All objects are at Y = 0.
However, around 10% of the time, instead of starting to chop, they just stop in front of the tree and stand there:
My code is in a simple state machine:
public void Update()
unit.stateMachine.ChangeState(new ChopTreeState(unit, tree));
If you set the destination to the tree it might not get close enough for it to consider the destination reached. E.g. if the destination is in the middle of the tree it might only get to say within 1 meter from the tree and that might not be close enough depending on your settings.
You can adjust this using the “end reached distance” on the agent or by setting the destination to the closest point on the navmesh instead.
ai.destination = AstarPath.active.GetNearest(somePoint, NNConstraint.Default).position;