I'm in a situation where I need a 2d sensor that will not collide but will also give me contact points for a collision.
Triggers don't give me contact points and colliders give me contact points but cause a collision.
I've tried disabling collisions when using colliders in the hopes of getting a collision enter callback but not having the collision actually occur, but no luck.
So how do I get contact points from a trigger? Or how do I get a collision callback with rigidbodies without causing a collision?
Basically I have a circle that I want to act as radar, but I'd like it to be fairly accurate with contact points too.
You should use OnCollisionEnter
but add a rigidbody
to it and set isTrigger
to false
and set rigidbody isKinematic
to true
then it will act like a trigger and you can get the contact points like this
void OnCollisionEnter(Collision collision) {
foreach (ContactPoint contact in collision.contacts) {
Debug.DrawRay(contact.point, contact.normal, Color.white);
}