GameMaker Jump Through Platforms

JeanSwamp

Member
So today I was trying to fix something that I've been delaying for a long time, and I actually managed to fix it.

Now the problem is, somehow I managed to mess up and forgot what was the thing that I had to change in order for it to work.

The problem I'm having is this:

When standind on top of a jumpthrough platform, if I overlap with anotherone, it will cause the player to fall.

This is how the code looks like:

Code:
var vcollide;
vcollide = instance_place(x,y+vsp,oJumpTh)
if (vcollide != noone)       
{
    if (bbox_bottom < vcollide.bbox_top) && !(state == states.ladder) && !downready
    {
        if (!place_meeting(x,y,vcollide))
        {
            while (!place_meeting(x,y+sign(vsp),vcollide))
            {
                y = y + sign(vsp);
            }
        vsp = 0;
        }
    }
}
Playing around today I changed some stuff and I managed to fix it, somehow I'm stupid and must have undo it.

Everything else is working just fine.

Hopefully someone can point me out the mistake
 

Attachments

T

Timothy

Guest
You simply need to check ALL jump through platforms you are colliding with. For each one, if previously above it, snap to the top of the platform. Collision event is great for things like this. GMS really needs a collision function that returns an array of instances.
 

jonjons

Member
I can give you a way that i use to check in witch platform the entity is walking on... is works for both player and enemies, and they can jump trow platforms.

paste this code right at the beginning of the step event
Code:
var check =    collision_circle(x, y+17, 3,  obj_Platform_Rotation, 0, 1); //
var check2 = collision_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom-1, obj_Platform_Rotation, 0, 1); //-obj_Platform_Rotation is the platform the entity can jump trow

if ( check != noone && check != check2 && platGo == 0 && vsp >= 0 )
{
    wallWalk = check;
}
else
{
    wallWalk = obj_wall_Parent; //-obj_wall_Parent is a solid wall and parent for rotation wall
}

//------------//-----//-----
//------//--GOING-THORW-PLATFORMS--//--------------------------------
if (  key_Down && platGo == 0)
{
    platGo = 0.5;
}
if (platGo > 0)
{
    platGo -= room_speed/1000;
    platGo = clamp(platGo, 0, 1);
}

in the create event
Code:
wallWalk = obj_wall_Parent;
platGo = 0; //--GOING-THROW-PLATFORMS--

Its important that you know whats happening in the draw event paste this code
Code:
draw_text(x-30, y+100, "wallWalk " + string (wallWalk));
draw_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom-1, 1);
draw_circle(x, y+17, 3, 1);

When the small circle touches the platform below, and the bbox square is not inside the wall and platGO is less or equal to zero that platform becomes active... else the entity will fall trow the platform.

heres a video of how its working... the platforms tickness are the minimum of 16 in height... has you see in the step event (( var check = collision_circle(x, y+17, 3, obj_Platform_Rotation, 0, 1))) the y+17 leaves only 1 pixel of gap its should be very precise.
 
Last edited:
Top