Want to jump through the bottom a platform and land on top of it.

Hey guys. Working on a 2d platformer.

Right now we’re trying to jump up from under a platform and land on top of it. What would be the best way of going about this? Thanks.

not really sure, maybe raycast from the bottom of the player, pointing up, if it hits the platform you could ignore collisions with it?

Thanks! Got it!

Or just change the collision layer of the player, whenever the player’s velocity is going up, and turn it on when the player is going down. This is the highest performance and will not lead to issues where the raycast misses the platform near platform edges.

You can change the collision layer with gameObject.layer = n;

n would be whatever layer you reserve for this, ie 20. Be sure to name the layer in unity’s layer dialogue. Call it jump.

Next, you set up the collision masks in unity by going to edit physics options in the editor. Make it so that the jump layer can collide with enemies but not playform, and the normal layer collides with everything.