示例#1
0
 //Adds object to the list of tracked collisions.
 public static void TrackMyCollisions( this GameObject self )
 {
     trackedColliders.Add ( self, self.BoxToRect() );
 }
示例#2
0
 // This lets you update the collision rectangle in case it changed/moved.
 public static void UpdateMyCollisions( this GameObject self )
 {
     trackedColliders[self] = self.BoxToRect();
 }
示例#3
0
    // 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 );
    }