Game Development Reference
In-Depth Information
1:
{
2:
instance_deactivate_object( obj_ledge );
3:
4:
x = xprevious;
5:
y = yprevious;
6:
7:
move_to_contact_with( direction, -1, obj_solid );
8:
9:
if( place_meeting( x, yprevious+vspeed, obj_solid ) == true )
10:
vspeed = 0;
11:
else
12:
y = yprevious+vspeed;
13:
14:
if( place_meeting( xprevious+hspeed, y, obj_solid ) == true )
15:
hspeed = 0;
16:
else
17:
x = xprevious+hspeed;
18:
19:
if( check_standing_on( obj_platform, 1, 0 ) == true )
20:
instance_change( obj_flynn_land, true );
21:
22:
instance_activate_object( obj_ledge );
23:
}
This approach doesn't stop ledges from working, as there is an entirely separate collision
event with
obj_ledge
that gets called independently when the character lands on a ledge. Even
if it causes Flynn to pass through a ledge in some obscure situations, this is a price worth paying
in order to solve our problem with Flynn getting stuck so easily.
Empty Collisions
One final thing we need to do to fix the ledge problem is to make sure that all our other
character state objects have empty collision events with
obj_ledge
. We already have one of
these in place for
obj_flynn_land
to make sure that sideways collisions with
obj_ledge
are
ignored when Flynn is walking. It is simply an
Execute Code
action containing the
exit
command, meaning “do nothing”—and significantly
don't
call the general collision event with
obj_solid
that would otherwise bring Flynn to a halt. The same events therefore need to be
adde d to
obj_flynn_ice
and
obj_flynn_wall
to cope with the extra potential for Flynn to have his
body wi thi n a l e dg e whi l e doi n g some thi n g e l se .
All these tweaks work together to fix the original problem we had with Flynn getting stuck
be twe e n l e dg e s. Pl a y
shadows1.gmk
from the
Chapter11/Games
directory on the CD and see for
yourself.
Search WWH ::
Custom Search