I am using a plug-in that handles collision detection of my sprites in a 2D environment. I would like to access the contact.point in OnCollisionEnter, but cannot seem to find a method to extract the information without calling the OnCollisionEnter. Any thoughts?
Contact points are only reported in OnCollisionEnter/Stay, both occurring in the physics cycle (50 times per second). But if you want to have the contact points available outside these functions, you can make a copy inside them and access the copy in any function:
var contact: ContactPoint; // saved contact point function OnCollisionEnter(coll: Collision){ contact = coll.contacts[0]; // save the first contact point }
Copying the first contact is faster and solves most cases, but you can copy the entire contacts array as well:
var contacts: ContactPoint[]; // contact points saved function OnCollisionEnter(coll: Collision){ contacts = coll.contacts; // save contact points }