I’m currently working on a 2D side-scrolling game similar to Mario using Phaser 3 for the game framework and Rapier.js as the physics engine. I’m seeking some guidance or code examples on two specific challenges I’m facing:
Preventing Sliding on Slopes: When my character moves on a slope, they tend to slide down even when I’m not pressing any movement keys. I need help in implementing a solution where the character doesn’t slide down the slope and stays in place if no input is given.
Bypassing Collision on Specific Sides of Objects: I have polygonal and rectangular objects in my game, and I want to bypass or disable collision detection on specific sides (e.g., allowing the player to pass through from below but not from above). I’m looking for a way to implement this behavior using Rapier.js.
If anyone has experience with these mechanics or could point me to any resources, examples, or code snippets, it would be greatly appreciated! Thanks in advance.
In this way, if your player is lower than the platform(which means player is passing through from the bottom side), the callback function will return false, than the collison will be ignored.You can design your own callback function to build more complex logic.