Implementing arrive
Arrive is similar to seek. The only difference between seek and arrive is that in arrive the player will stop at the target location. However, in seek, it overshoots the target location and then seeks again.
Getting ready
The technical definition of arrive is to reach the goal with zero velocity. The arrival behavior will remain the same as the seek behavior, the only difference is that it will not overshoot the target.
In this approach, when the player is outside the stopping radius, it will follow the maximum speed toward the target, while as soon as the player is inside the stopping radius, the desired velocity of the player will be ramped down to zero.
How to do it
Perform the following steps to implement the arrive behavior:
Open the Player.m file, and add the following line of code in the end of the file:
- (void) arrive:(CGPoint )target deltaTime:(float)deltaTime { // Work out the direction to this position GLKVector2 myPosition = GLKVector2Make(self.position...