ArcRotateCamera is stuck in collision detection

I created an ArcRotateCamera with the parameters set as:

My scene is an imported gltf model, which contains several buildings and a ground. The interior of the buildings are hollow and can be passed through.I have used collision detection for each Mesh in the scene, and ArcRotateCamera has also enabled collision detection.

      result.meshes.forEach(mesh => {
        mesh.checkCollisions = true;
      })
    scene.collisionsEnabled = true;
    camera.checkCollisions = true;

But when I moved the camera, I found that it would get stuck when passing through certain buildings.
As shown in the picture, I use the top midpoint of building A as the target of ArcRotateCamera. When I approach building A until ArcRotateCamera passes through it, it will not get stuck, but when ArcRotateCamera passes through B, it will get stuck.

Any idea what causes this issue? Thanks in advance!!

Hi, I found a similar problem. I couldn’t come out after entering the model, I couldn’t even rotate the lens, or I couldn’t move it when attached to a wall. Almost all walls in the model I used were composed of extruded splines. so how can I deal with it? Should I modify the code or modify the original model?

And this

Adding @Cedric and @RaananW who master maths physics

1 Like

Hard to say without a playground and some experiements.
Did you try to increase collisionRetryCount ?

2 Likes

thank you, but sorry it seems that there isn’t a property named collisionRetryCount, only occlusionRetryCount. :disappointed_relieved:

I am considering whether it is a model problem. I want to perform collision detection on an entire building. The desired result is that when the camera touches any part of the building, it will collide and move away. Based on the content of the two forums I mentioned earlier, I guess that maybe the camera is stuck in the model.

The model of the building is not a whole, its mostly includes: an editable poly in the middle, the ceils and the surrounding walls are all extruded Editable Spline, and all of the components are not combined into a group.

When I hit the surface of a building with a camera, sometimes it seemed to be stuck to the surface, sometimes stuck in the wall, and sometimes stuck inside after passing through the wall (I have set the minZ of the camera to 0.1 and it can pass through the wall).

I don’t know much about modeling, this model is provided by others, so I don’t know how the creation and organization of the model affects the collision.

Sorry for my cumbersome expression, if you can understand what I mean, can you give me some suggestions?

I think it is indeed the problem of the model. After I changed the model, the above problem did not occur.But I still want to know what is wrong with the previous model :disappointed_relieved:

1 Like

Make sure the model’s normals are pointing outwards and that the model is not, for some reason, inverted. The collision relays on this data and if it is wrong you will be “stuck” inside the model.

5 Likes

Thank you for your explanation!

Here it is - Babylon.js docs :slight_smile:

2 Likes

Thank you, I think I must be blind that time… :sweat_smile:

1 Like