Game Development Reference
In-Depth Information
Also the text in the output window confirms that we have managed to move three
identical spheres in three different ways:
Sphere 0:80
Sphere 1:80
Sphere 2:80
By now you have learned the basics of forces that you can apply to a body. Anyway,
this task was quite easy because you applied forces to sleeping bodies. It would have
been much more difficult to achieve the same result with bodies that are already
moving or colliding with each other.
While you are free to apply forces in the way you prefer, the following are useful
suggestions about which kind of force you should apply according to the game you
are developing:
• Set a linear velocity when you want to stop a body no matter what it was
doing, and apply a brand new motion. In game design, think about a moving
platform or an enemy patrolling the area: at each time step you can set its
linear velocity and it will move straight in one direction.
• Apply an impulse when you want to apply the entire force in one single time
step, adding it to existing forces. In game design, a jumping character will
use impulses to jump.
• Apply a force when you want to give your character a thrust through
time, such as a jetpack or the way to control the ball in Ball and Ball
Revamped series.
But, above all, experiment! The same things can be done in different ways, it's up to
you to find the way to apply forces that fit your needs.
 
Search WWH ::




Custom Search