Compound Collision with no Rigidbody

Good afternoon all,

I’m working with some compound collision objects for raycasting purposes, and I’m noticing that they don’t respond to raycasts without the rigidbody component. All of the other collider types will work when firing a raycast except for compound unless the rigidbody component has been added. Is this intended?

Hi @eproasim,

How are you doing your raycasts? Using the rigidbody system raycastFirst/raycastAll methods? Or something else?

As far as I know those methods do require a rigidbody component since they need to be added to the physics world for the Ammo.js raycast to work.

Hi @Leonidas!

Thank you for responding. It’s funny because I am using this.app.systems.rigidbody.raycastFirst(), but on this project and on previous ones my raycasts respond normally with only the CollisionComponent, assuming that I use primitive colliders.

I guess looking back at the function it makes sense that I should need a rigidbody, but I haven’t so far which makes the confusion a bit more weird.

I’ve since just adjusted my pivots on my models to get the colliders where I wanted them. In some ways if my current usage working is a bug I don’t want it fixed! :slight_smile: I like not having to be bound to the rigidbody, and if that means I’m only limited to primitive colliders, I think I can live with it.

Right, it’s then the case of an entity that acts as a trigger (collider with no rigid body component) they are still being consumed by Ammo. Interesting that they respond to raycasts, you can definitely raise an issue about compound colliders not working if that’s the desired behavior for triggers.

In general you could also use the Bounding Box and Sphere classes to get away with using physics for raycasts. It could work with compound shapes potentially, with extra work though.

https://developer.playcanvas.com/en/tutorials/entity-picking-without-physics

1 Like