Get position and rotation where trigger collision occurs?

I have a trigger, which is working fine, but I want the position where the collision occurred, not the EntityA or EntityB’s position.

Where do I look for this data?

Thanks

To my knowledge, there is no built in method to find out what point a trigger has been hit.

The OnTriggerEnter() function just gives you the other gameobject’s collider, but does not give you any actual information about the collision itself.

If you have two rigidbodies and use the OnCollisionEnter() function instead, you can get all sorts of information about the collision itself as that function passes a Collision class, which has the property that you want (specifically, you can use Collision.GetContacts to get all the points where the collision happened).

Depending on the shape of your colliders, you might be able to use raycasts to get a vaugely close estimate of where the collision happened, but otherwise I won’t be able to help you (I am sure you can do a bunch of math to figure out where the collision happened yourself, but thats beyond my knowledge!)

Thanks for the info.

I should have been more specific about that I am ref ECS, not MonoBehavior. However the TriggerEvent in ECS also does NOT seem to have the collision position/rotation.

1 Like