AI Path following broken in 1.8.0?

Figured out what’s happening after consulting the source code™:

The path walker has a hardcoded distance threshold of 5 units for each target, so walkers will always cut corners 5 units in front of their goals (except for the last node, which the walker regards as reached 1 unit too early :wink:. If the playing field was larger, this would cause less of an issue, but since my units have a unit length of 0.25, this is a pretty grave violation.

I solved the problem by hacking around: each target point is extruded 5 units along the direction vector, except the last point which only needs to be extended by 1 unit.

Here’s my code that produces the correct, expected results

        agent.node.setPos(self.node.getPos())
        ai = agent.ai_behaviors
        ai.pathFollow(1.0)
        pts = []
        lastpos = self.node.getPos()
        for i,wp in enumerate(self.wp):
            pos = Vec3(wp.node.getPos())
            mpos = pos
            if lastpos:
                d = pos - lastpos
                d.normalize()
                if i < (len(self.wp)-1):
                    mpos = mpos + d*5
                else:
                    mpos = mpos + d
            lastpos = pos
            pts.append(mpos)
        for pos in reversed(pts):
            ai.addToPath(pos)
        ai.startFollow()