//Adds object to the list of tracked collisions. public static void TrackMyCollisions( this GameObject self ) { trackedColliders.Add ( self, self.BoxToRect() ); }
// This lets you update the collision rectangle in case it changed/moved. public static void UpdateMyCollisions( this GameObject self ) { trackedColliders[self] = self.BoxToRect(); }
// Use this one on your game object like so: gameObject.Colliding( otherGameObject ); public static bool isCollidingWith( this GameObject self, GameObject other ) { if ( !self.collider2D.enabled || !other.collider2D.enabled ) return false; Rect aBox = self.BoxToRect(); Rect bBox = other.BoxToRect(); // Find out if these guys intersect return Intersecting ( aBox, bBox ); }