O'Reilly logo

iOS Game Programming Cookbook by Bhanu Birani, Chhavi Vaishnav

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the seek

To implement the seek behavior for our player, we will need a derive force that will redirect the agent toward a target position. In the seek behavior, our character will overshoot the target because the force applied on the player will be more, which will make the player overshoot the target and then return to the target. It will take a finite amount of time before coming to rest.

Getting ready

Seek behavior is something similar to the following screenshot:

Getting ready

The preceding image explains the algorithm that will be used to implement the seek behavior. In our case, we will need to seek to the target and have to follow the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required