Game Development Reference
In-Depth Information
The other part of the last step (lines 50 through 55) applies in cases other than jumping
(being in air). Here we have two possibilities: the y position of the object is either 0.5, or
less than that. Values less than 0.5 can be caused by gravity displacement in the previous
step. Since displacement depends on delta time, which we cannot control, we cannot guar-
antee the absence of values less than 0.5 (remember that we still have no collision detection,
so the ground will not prevent the character from sinking). To be in the safe side, we reset
the vertical speed to zero and make sure that our object y position is 0.5.
When you are done building the scene as in Illustration 17 (or any similar scene, as long as
it has objects in the background to recognize movement), and add PlatformerControl script
to the player character, you are ready to run the game and test movement and jumping.
Illustration 18 shows a screen shot from the game during jump.
Search WWH ::




Custom Search