Hey I was wondering if anybody can help I am trying to find a way to compare the position of 2 rigidbodys and when one object is directly above the other destroy the one underneath. I could use hitboxes but with having multiple instantiated objects I think comparing the positions may be the better way to go.
Replies
float tolerance = 0.01; if ( (Mathf.Abs(lowerTransform.position.x - upperTransform.position.x) < tolerance) && (Mathf.Abs(lowerTransform.position.z - upperTransform.position.z) < tolerance) ) { Destroy(lowerTransform.gameObject); }