• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Gravity Flip with Jump-through platforms

Hello! I am working on a platformer using the excellent Moving Platforms package by ZBG as a basis. I think I have a pretty good understanding of how it works and have made a lot of modifications. But, I've hit a wall when I tried to add a Gravity Flip mechanic. It works great on regular solid blocks, but when it comes to the Jump-Through platforms or semi-solids, things started getting weird. It works fine when the gravity is normal, but when flipped, the player sticks to the jump-thrus when it isn't supposed to (for example, while jumping up through, rather than when coming down onto it), frequently fails to stick to them when it's supposed to (it falls right through) and when it does land on one, it gets stuck and can't seem to jump off.

Here's a fun gif showing the problem:
helpJumpThru.gif

Affecting my character was easy, using a "gravity facing" variable set to either 1 or -1, I changed things like gravity application or jumping direction by multiplying them against it. Within the functions created for colliding with platforms, I figured all I'd need to do is change the directions being checked according to the gravity direction, but as I said, it didn't work so great!

Rather than continuing to toil on my own project where I could have made any number of possible mistakes, I went back to the original and tried applying the gravity flip there instead, and got it into the same state. The relevant code is below, but I could easily be missing something, so I'm also including a link to the modified version of Moving Platforms as well. (I assume this is ok, since the package has been free for some time but I'll remove it immediately if anyone thinks I should.) The only significant changes I've made are the additions of the gravFacing variable and a non-parent version of the jump-through platform (for some reason that wasn't included).

Any help would be greatly appreciated!

The "OnGround" Script:
Code:
/// OnGround();
return place_meeting(x, y + 1 * gravFacing, oParSolid) || (place_meeting(x, y + 1 * gravFacing, oParJumpThru ) && !place_meeting(x, y, oParJumpThru));
The "PlatformCheck" Script:
Code:
/// PlatformCheck();

var collision = instance_place(x, y + sign(vy), oParSolid);

if (collision) {
    if (vy >= 0) {
        platformTarget = collision;
    } else {
        // Platform above
        vy = 0;
    }
    return true;
}

if (vy < 0) {
    platformTarget = 0;
}

if (instance_exists(platformTarget)) {
    if (platformTarget) {
        if (place_meeting(x, y + 1 * gravFacing, platformTarget) && !place_meeting(x, y, platformTarget)) {
            //Platform below
            vy = 0;
            return true;
        } else
            platformTarget = 0;
    }
} else
    platformTarget = 0;
   
if (vy > 0) {
    with (oParEntity) {
        {
            if (place_meeting(x, y - 1, other) && !place_meeting(x, y, other)) {
                vy = 0;
            }
        }
    }
   
    with (oParJumpThru) {
        if (place_meeting(x, y - 1 * other.gravFacing, other) && !place_meeting(x, y, other)) {
            // Land
            vy = 0;
            other.platformTarget = id;
            return true;
        }
    }
}

platformTarget = 0;
return false;
Moving Platforms with Gravity Flip
 
Top