Enable collisionMask and collisionGroup on camera / ellipsoid

Similar to mesh.collisionMask and mesh.collisionGroup , it would be useful and logical to allow the same properties on the camera. and use them in collision mechanism

Currently camera only has camera.checkCollisions and camera.ellipsoid.

USE CASE
We have a 3rd person controller: ArcRotateCamera and a target mesh (avatar).
We want the avatar to collide with object A and object B.
We want the camera to collide with object A only, and NOT with object B.

Object A are typically large objects (walls, floors) and object B small items like small rocks that should not block the camera but make the avatar go over them.

camera.onCollideObservable seems not work as GPT suggested.

Alternative Method - Camera Collision Example
escalator work | Babylon.js Playground (babylonjs.com)

Mesh Collision Example
Collision/Intersection Demonstration | Babylon.js Playground (babylonjs.com)

I think mesh.checkCollisions is what you want?

Mesh.checkCollisions and ArcRotatecamera.checkCollisions both exist and work as expected.

Mesh.collisionMask and Mesh.collisionGroup also exist which is a great feature.\

ArcRotatecamera.collisionMask and ArcRotatecamera.collisionGroup DO NOT exist and would be great to have for above mentioned use case…

Thanks!

Sorry, I did not read your first post correctly.

That seems leggit, what do you think @Cedric?

ATM none of the camera’s are passed to the collisionCoordinator, ( excludedMesh variable ).
I can’t see any harm of passing it, as a extra bonus it’ll allow for camera.surroundingMeshes array aswell :slight_smile: !

Coordinator.getNewPosition continues into coordinator._collideWithWorld
Where collisionMask & surroundingMeshes are retrieved from excludedMesh :slight_smile:

Camera would only need a collisionMask though

3 Likes

One would need to double-check that but if so this is definetely an upvote from me :smile:

I upvote as well. Seems like a good idea (Happy to review the PR)

Yes, works for me as well. And happy to review it.

@Evgeni_Popov @Cedric do you have information on when this feature will be released? is there a place i can check for the status of feature requests in general? Thanks !

It’s not currently in our plan, but if anyone in the community is willing to contribute, we’ll be happy to look into the PR!

You can visit Issues · BabylonJS/Babylon.js · GitHub to see our plan for the coming months (but we can add new issues to the list at any time).