Camera Collision with Extruded Shapes

Hi
I am trying to apply the principle of camera collision on extruded shapes along what is described in the doc here: Cameras, Mesh Collisions and Gravity - Babylon.js Documentation

I have an issue when I am using ExtrudePolygon in place of the simple box used in the doc.

When colliding the extrudedPolygon, the camera is actually entering the shape and is stucked to it. The camera cannot escape the shape any more.

While on the other side, when colliding the box, the camera is remaining on the box surface and can go back on the initial position.

Here is a simple PG illustrating the issue: https://www.babylonjs-playground.com/#U8MEB0#173

On the right, the box that is reacting “correctly” to the collision.
On the left, the extruded shape that is trapping the camera on collision.

The behavior looks strange and I am wondering whether it is a bug or a feature.

How can I solve this?
My need is to have a parametric shape with proper collision behavior.

Thanks for the help!

Hi and welcome to the forum!

Not saying this is a solution, but this is not a collision issue. The mesh is actually built inside out for some reason. See this - https://www.babylonjs-playground.com/#U8MEB0#174 . The side orientation is front side, which should create a mesh that is just like the box - normals towards the outside. but it seems like the box is inverted. Notice that once you are IN the box, collision works correctly - you can’t get out :slight_smile:

Make the side orientation back-side - https://www.babylonjs-playground.com/#U8MEB0#175 , and collision works as expected.

1 Like

Hi!

Indeed, you are right. The mesh is built inside out… I tried to invert the coordinates order of the shape array but it does not change it.
Anyway, flipping the side orientation is solving my issue. That’s great!

Thanks for the help!

1 Like