Freeze mesh position

How can I completely prevent a mesh from falling off a platform? I’m working on a 2.5d game and I have that issue that if you walk and jump too frequently the player just fall off from the platform.

Heres the example playground: https://playground.babylonjs.com/#0V7KM3#11

In this playground you can jump with W and run around with A and D. If you hold W and walk arround you will fall off the platform after while.

What I tried

  • Crate plane walls surrounding the path
  • Add a setLinearVelocity(movement.x, movement.y, 0)

I was wondering if is there a “hidden function” just like the serAngularFactor, but something like setLinearFactor for linear speed.

I think the invisible walls would be the best solution in gameplay terms, you said you tried it, what was the result?

1 Like

The walls had no effect actually, after a while the player got pushed off the platform just like the walls wasnt there :confused:

If collisions were set correctly and still the player can penetrate walls, probably walls normals are inverted. Try to rotate your wall 180 degrees and see what will happen :slight_smile:

2 Likes

Another thing to make sure of is the height of the walls, make them higher than needed to be safe (I watch way too many speedrun history videos to know walls are a very common source of OOB trickery :rofl: )

2 Likes

Hey, I did it, but it stills falling, its more consistent now, but it stills falling very easy :frowning:

Here the test I did: https://playground.babylonjs.com/#0V7KM3#13

I was trying to fall on the PG you provided but wasn’t able to, it worked pretty well :thinking: another thing to try would be to add a bit of thickness to the walls, to avoid a situation where the character moves so fast they pass through?

1 Like

I let it thicker and it worked! Thank you!

2 Likes