Hello,
I know how to find Contact point of collider when object collides with other object using OnCollisionEnter2D(Collision2D other) method.
but suppose i touch on some object, how can i get the contact point on touch?
Hello,
I know how to find Contact point of collider when object collides with other object using OnCollisionEnter2D(Collision2D other) method.
but suppose i touch on some object, how can i get the contact point on touch?
Every collision has a array of contact points. Each contact point has a position where the collision occured. So you need to get those contact points in order to get the collision position.
void OnCollisionEnter(Collision collision)
{
for(int i = 0; i < collision.contacts.Length; ++i)
{
ContactPoint contact = collision.contacts*;*
Debug.Log(contact.point);
}
}
Collision points:
[Unity - Scripting API: ContactPoint][1]
[1]: Unity - Scripting API: ContactPoint