Typically, when starting a platformer prototype in Game Maker, I whip out a few scripts that I've come to love from Matt Thorsen's Grandma Engine.
One of the scripts checks to see if the player is on the ground, as well if the player is on top of a platform, but not colliding with a platform. This handles both solid ground and jump-throughs (to a certain extent).
// Original code with names changed to suit my project
return place_meeting(x, y + 1, oParentFloor)
|| (place_meeting(x, y + 1, oParentPlatform) && !place_meeting(x, y, oParentPlatform));
Simple, but you can't stand on a platform while colliding with a different platform. Say you
use them as stepping stones and the player or an enemy is taller than two platforms that are stacked. Hopefully that makes sense?
So basically, I need to check if you're standing on a platform and not colliding with that same platform. I have come up with several ways to do it that work in 'most' cases. I also came up with a way to do it that seems very slow and troublesome (but it works).
// Slow, but useful
with (oParentPlatform) {
if (place_meeting(x, y - 1, other) && !place_meeting(x, y, other))
with (other)
if (place_meeting(x, y + 1, other))
return true;
}
return place_meeting(x, y + 1, oParentFloor);
Any advice on ways to do it differently or speed it up?
EDIT: For example, I can use instance_place() to return the ID of the platform I'm standing on and compare that to the platform I am colliding with. There are issues with that though; the big one being that instance_place() returns the first instance and you could be colliding with several. That is where I got the idea to step through the platforms with with().