I build a very simple example in playground to start understanding Agent/Behavior/Goals. I was able to add a goal for toReachTargetSpeed, but my second test was to add a wander goal. I thought I understood the speed parameter but it just seems to produce very little wander movement. Here is the example I use:
import GameplayKit
@available(iOS 9.0, *)
func testAgent() {
let agent = GKAgent2D()
agent.mass = 2
agent.maxAcceleration = 90
agent.maxSpeed = 120
agent.radius = 5
agent.position = float2(x:0,y:0)
agent.rotation = 0
agent.behavior = GKBehavior(goal: GKGoal(toReachTargetSpeed: 110), weight: 1)
agent.behavior!.setWeight(5.0, forGoal: GKGoal(toWander: 90))
for _ in (0..<80) {
agent.updateWithDeltaTime(0.05)
print(agent.position)
print(agent.speed)
}
}
if #available(iOS 9, *) {
testAgent()
}
The results are: (just the last 2)
float2(246.718, 4.70492e-18)
95.7104
float2(251.523, -2.50744e-18)
96.0825
So Wander does add a small change in the Y position, but very tiny. Any idea where I'm wrong?
Thanks,
Shay