How to prevent the ball from falling through?

Hello,

I created a simple game, where you can move a ball through a maze using two sliders which tilt the maze.

If I tilt too fast, the ball falls through the ground mesh. How can I prevent this?

All of the code is visible at GitHub - Myrmod/MazeRiddle
The code of the ball is here: MazeRiddle/index.js at main · Myrmod/MazeRiddle · GitHub
The code of the ground is here: MazeRiddle/index.js at main · Myrmod/MazeRiddle · GitHub

I would use a box mesh instead of a ground mesh so that you can set the depth.

edit: I haven’t used built-in physics impostors in a while, but maybe you can increase the depth of the ground’s physics impostor.

2 Likes

For some cases it would work with a box. I tried an invisible Box below the Ground mesh, which also helped somewhat. Thanks for the tip.

I found a solution with using forces instead of rotation. This doesn’t look as cool on the desktop though, but you cannot catapult the sphere like that, so I am not sure if I like this approach.

Another solution might be to reset the position of the sphere onBeforeRender or something.

I think I will either let the ball fall through sometimes or restrict it altogether. Was a nice idea.