How to create one way platforms?

FunnyLucky

  • Posts: 14
Many threads with the same question have no screenshots and only some general directions to the solution. Can someone explain how exactly do I create a platform that only has collision if the player is above it?

JeffreyDriver

  • Posts: 2262
If your platform is an actor, you can remove and replace it's collision shape (or turn it to/from) a sensor depending on the Y value of your actor. So if your actor's Y value is less than the platform's Y value, turn collision on, otherwise turn it off.

You'll need to account for your actor's height when calculating this.

If you're using tiles it's still easily possible, but a little more complex.

FunnyLucky

  • Posts: 14
My current thinking plan is to make a Game Attribute for player's Y that updates every frame and when it's lower than the platform's it gets collision. Will that work, because it feels like I'm missing the entire point...

rature

  • Posts: 21
Hi !
Your current thinking plan works if you use actors as platforms :
First create two groups :
- one collides with your player
- the second does not collide with your player

Then put in the Actor Platform event :
When updating
If Y of self > Y of Player + Height of Player
Then For each collision shape of self
Set collision group to "group collide player" for collision shape
Otherwise
For each collision shape of self
Set collision group to "group doesn't collide player" for collision shape

(see the attachment)

If you want to use Tiles instead of Platform Actors :
Create 3 animations for your player : idle , jump , fall
idle has a collision box group  "collide with tiles"
jump has a collision box group  "doesn't collide with tiles"
fall has a very small collision box (1px high) on the feet of your player with "collide with tiles" group
+
the collision box of the one way tiles : 1pixel high

hope it helps, (sorry for the english mistakes, i'm french)
I'm working on something based on these two solutions, and for the moment it works well.
Would be very cool, some day, to have the one way platform option in the tiles editor ;)
follow me :  https://rature.itch.io/  :)