• 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!

GameMaker Making solid platforms you can press down to fall through

FacesOfMu

Member
Given that the word "platform" also means OS/Device, this topic is really hard to research without more commonly used labels.
In my 2D platformer game, I'm looking for a way to create platforms that:
- entities can fall onto
- the player/AI can press down to fall through them
- they don't block horizontal or vertical movement when an entity is overlapping it
If this doesn't make sense, think of the platforms in Terraria, or bridges, branches, and crates in other games.

Are there elegant and well known solutions most designers use for this? Do you have your own jimmy-rigged method? What about when you can place and remove crate-like platforms (they have an entire square sprite but only the top edge is the collideable platform). Please let me know!
 

NightFrost

Member
The basic idea with one-way platform objects is that you use them for vertical collision only if A) your vertical speed is above zero (falling downward) and B) player is above the one-way (player bbox_bottom is less than platform bbox_top). When vertical speed is less than zero the collision check ignores them. Horizontal collision check always ignores one-ways and only tests for objects that are considered solid walls.
 

NightFrost

Member
Above or equal to zero, so you can walk on top of them without falling through.
Ah yes, this depends on the exact code implementation. Mine applies gravity to vspeed (that is, makes character fall) only in jump/fall state, and switching to that state is governed by a separate ground check (and player executing a jump of course).
 

FacesOfMu

Member
The basic idea with one-way platform objects is that you use them for vertical collision only if A) your vertical speed is above zero (falling downward) and B) player is above the one-way (player bbox_bottom is less than platform bbox_top). When vertical speed is less than zero the collision check ignores them. Horizontal collision check always ignores one-ways and only tests for objects that are considered solid walls.
You're right! I remember now that the last time I tried to make a platformer years ago, I was using the platform's whole collision area and struggling to get my character to keep falling all the way. bbox_top makes so much more sense!
 
Top