#Collision events not working

1 messages · Page 1 of 1 (latest)

tight cipher
#

I have a cube that starts in the air and falls onto the floor. Collisions are definetely working, as the cube hits the floor and then stops, but no collision events seem to be firing. Using the PhysicsDebugger, and ticking "draw collision events", nothing is being drawn to the screen when the collision actually happens. The setup is simple, just a cube with an RB and a boxCollider dragged into a subscene, giving the entity in the image - what am I missing here? I do have a job to try and log out these collisions as they happen (which doesn't seem to work), but given no collision events are being drawn in the first place, I assume there's a problem with the events before even getting to the job.

This feels like it should be a super simply process, but I must be missing something? The docs say "Collision events are raised from colliders that opted in to this behaviour", but doesn't actually tell me how to opt in: https://docs.unity3d.com/Packages/com.unity.physics@1.0/manual/simulation-results.html

tight cipher
#

Yeurgh, if I swap out my BoxCollider for a PhysicsShape (from the samples package), collision events are raised correctly. Is there really no way to detect collisions without using the PhysicsShape? This really, really feels like it should be built in UnityPhysics functionality... when I compare the actual ECS components at runtime between the box with the PhysicsShape and the box with the Collider, they both have the exact same components (although I can't see the properties of the resultant PhysicsCollider component, I can just see the hash), so presumably something to do with the setup of the PhysicsCollider component is different when using PhysicsShape?

tight cipher
#

Easy fix in the end...

BlobAssetReference<Unity.Physics.Collider> colliderBlobAssRef = Unity.Physics.BoxCollider.Create(boxGeo); PhysicsCollider physCol = new PhysicsCollider { Value = colliderBlobAssRef, }; physCol.Value.Value.SetCollisionResponse(CollisionResponsePolicy.CollideRaiseCollisionEvents); ecb.AddComponent(newEntity, physCol);

At least, this is how to do it on an entity created programmatically, rather than dragging and dropping a regular GO into a subscene, but that was my usecase anyways

Not sure why I had such a hard time finding the SetCollisionResponse function, or why it isn't enabled by default!