Camera bounces back when colliding with meshes 2 (Camera Collisions)

Hello!

Here is the first post Camera bounces back when colliding with meshes (Camera Collisions) - #7 by Nawar

I decided to follow the solution from the first post and rework the 3D model. I have separated all the parts of the model and now they are independent from each other and do not create huge rectangles for the whole room.

But, despite my efforts, nothing has changed and the camera behaves exactly the same.

Link to playground with new model https://playground.babylonjs.com/#0VHCTL#6

Maybe I did something wrong with the model?

@Cedric is the king for those kind of issues :slight_smile:

1 Like

Seems that the problem is gone with commented line camera.applyGravity = true - https://playground.babylonjs.com/#0VHCTL#7
If you need physics camera collision you may get rid of default collision system and use it like in the example - https://playground.babylonjs.com/#4U5T2X#18

1 Like

Thanks for the answer!

Yes, without gravity, everything is fine, but the point is, I need gravity.

I think the second option is too complicated

In general, moveWithCollisions works very well with this map, but the camera does not have it.

1 Like

You already have gravity for the camera with setting camera.checkCollisions = true. If you need only gravity there is no need actually to use physics engine at all.
image
If you want moveWithCollisions - make a mesh and bind it to camera.

1 Like

Thanks for the answer!

I will try to describe the whole problem related to these two posts

The app I’m working on has multiple cameras. Including from the first person, from the third person. In third person mode, the arcRotateCamera follows the character who moves with moveWithCollisions, which always work out perfectly. Ideally, camera collisions would work in the same way as moveWithCollisions on meshes.

In general, all these two posts refer to one more camera. To the XR camera. I used to bind all cameras to a mesh and move around using moveWithCollisions. And everything was fine. But then I found that 6DOF stopped working in XR camera due to the fact that I copy the position of the character for the cameras.

Therefore, now it is not the cameras that copy the position of the character, but the character copies the position of the camera.

I need a physics engine for another part of the application

Looks like I solved this problem.

Because the only reason for the camera bouncing is the small height of the mesh, I add a box to it in size with an increased height and the camera collides with this box. Still, the solution doesn’t seem elegant. Maybe there is something better?

For example, how can I increase the height of the intersection box? I dug around in the documentation but only found how to change the boundingBox of a mesh. And he, as I understand it, is not a subject for collisions

My version https://playground.babylonjs.com/#0VHCTL#8

1 Like

You solution seems quite elegant for this purpose.

2 Likes