I am currently trying to make a pen draw on a paint. I am searching for contact points on the paint but there is too much contact points than expected.
I'm not sure to properly understand how collisions are detected. Only one side of the cube touches the paint, but four points are returned and seem to correspond to each corner of the cube projected onto the plane.
private void OnCollisionStay(Collision collision)
{
Debug.Log(collision.transform.tag);
if (collision.transform.CompareTag("Paint"))
{
Debug.Log("Pen enter collision with paint");
foreach (ContactPoint contact in collision.contacts)
{
Debug.Log(contact.thisCollider.transform.name + " " + contact.otherCollider.transform.name);
Debug.DrawRay(contact.point, contact.normal, Color.white);
}
}
}
OnCollisionStay(Collision collision)
and the editor's Physics Debugger is showing me 2 contact points, butcollision.GetContacts()
is reporting only 1. Maybe it's a bug? I'm on 2022.3.8f1. \$\endgroup\$