Falling Through One-Way Platforms

I

IE Entertainment

Guest
So, I was learning how to code a one-way platform where the player can jump up onto a platform from a position of standing directly under it. Think smash brothers. I found one of Shaun Spawldings tutorials and followed it but I am having one problem. While the player can jump through the platform, it isn't solid when the player lands so he just falls through the platform back to the ground. I couldn't find a fix from others who had the same issue so I am wondering if anyone of you guys may have ideas? Here is the code...
One Way Platform CREATE EVENT
sprite_index = -1;

One Way Platform STEP EVENT:
if (instance_exists(obj_player))
{
if (round(obj_player.y + (obj_player.sprite_height/2)) > y) || (obj_chroma.key_down) mask_index = -1;
else mask_index = spr_platform;
}

Thanks in advanced for the help!!!
 
I

IE Entertainment

Guest
I don't think that's the best way to do a jump-through platform, mostly because I've tried that myself a long time ago and I had the same problem.
Instead of using masks, just only do the ground collisions (in your player object I assume) for the jump-through platforms if the player's bbox_bottom is greater than the slopes.

For example, I do something like this to collide with my platforms:
Code:
/// Player Step Event
repeat(abs(speed_y)) {
    // Normal Solid Check
    if (!place_meeting(x, y + sign(speed_y), obj_solid)) {
        y += sign(speed_y);
    }
  
     // Jump-through Platform Check
    // Store the instance ID of the jump-through in a variable (instance_place is like place_meeting but it returns the instance ID of the object or "noone" if it found nothing)
    var jt = instance_place(x, y + sign(speed_y), obj_jt);
  
    if (jt != noone) {
        // This will make sure the player is above the jump-through before he makes a collision with it.
        if (bbox_bottom <= jt.bbox_top) {
            y += sign(speed_y);
        }
    }
}
I don't know how you do the player movement or collisions, but however you do the solid block collisions, just do basically the same thing but check "if (bbox_bottom <= jump_through.bbox_top)".
Awesome! Thanks for the help. As soon as I get a chance to, I will implement the code to see how it fairs. Thanks alot. I will let you know how it goes
 
Top