I have a simple SKScene
based game. I have a path that I've created using GKGridGraph.findPath
and I want my agents to follow that path exactly.
I've set up the agent to follow the path, with a radius of one, so it should be a pretty narrow path down the centre of the grid.
class EnemyAgent: GKAgent2D {
init(path: GKPath) {
super.init()
maxAcceleration = 1000
maxSpeed = 100
mass = 1.0
radius = 1.0
let followGoal = GKGoal(toFollow: path, maxPredictionTime: 1.0, forward: true)
let stayOnPathGoal = GKGoal(toStayOn: path, maxPredictionTime: 1.0)
behavior = GKBehavior(goals: [stayOnPathGoal, followGoal], andWeights: [50, 100])
}
The problem I'm having is that the agent seems to have a turning radius, maybe based on mass and acceleration, that is preventing it from sticking to the centre of the grid.
What can I do to force the entity to stay exactly on the path?