Camera bypasses collision

Hi there, I’m probably doing something wrong here, just wanted a bit of feedback.

I have a box, which is meant to be a boundary, where the camera can’t exit, but as soon as I hit the wall, the camera seems to glitch a bit and move out, and then it can’t go back in the box:

What am I doing wrong?

Thanks!

pinging our resident collision expert @RaananW

Hi!

The collision uses the normals to calculate the future collisions, so the side orientation of the constructed box is imported. if you want to stay inside the box, invert the box (so the normals go inwards):

Camera Constrained in bounds | Babylon.js Playground

Notice line 25 (sideOrientation)

1 Like

That’s it! thank you so much :smiley:

1 Like