Game Development Reference
In-Depth Information
Figure 5-2. Zool cannot collide properly with the platform because the 100pts instances are in the way
A Solid Problem
So what is happening here? Reopen obj_zool_air and select the Collision event with obj_solid .
This event is triggered by collisions with solid objects, such as when Zool lands on top of a
platform. There's nothing wrong with that, but now open the Move to Contact action within this
event. This moves the Zool instance downward until it comes into contact with all objects —and
all objects includes instances of obj_100pts .
The problem occurs when Zool lands on a collectible immediately before colliding with the
platform beneath it. The collision event with obj_solid will move him back to his position before
the collision, and then he should get moved down to the contact position with the platform.
However, he can't because there will be an instance of obj_100pts in the way that was created by
the collectible (see Figure 5-2). So he doesn't get moved down by the Move to Contact action and
there won't be a platform directly beneath his feet at the end of the Collision event. That means
he won't change into obj_zool_land and will float across the line of collectibles, until either he
reaches the end, or they eventually turn into twinkles and disappear. This may not seem like a
disaster, but think about it. Every new object we add to the game will start to interfere with
collisions even when they are not supposed to be solid. This is going to cause a huge number of
bugs and problems with our game!
The Solid Wheel
So at this stage you may be thinking the solution is simple: everybody knows that Game Maker
has a built-in option to distinguish between objects that should be treated as solid and those that
should not. All we need to do is enable this Solid option for all the different kinds of platforms
and then select the solid objects option in all our Move to Contact actions. Then the likes of
collectibles will be ignored and the problem will be solved. In fact, why have we been bothering
with this strange obj_solid object anyway—surely it's just reinventing the wheel? Why spend
time coding something that Game Maker already does for us?
 
Search WWH ::




Custom Search