Пример #1
0
    public static bool isHitFromAbove(float sourceMaxY, ChipmunkBody target, ChipmunkArbiter arbiter)
    {
        /// The collision normal is the direction of the surfaces where the two objects collided.
        /// Keep in mind that the normal points out of the first object and into the second.
        /// If you switch the order of your collision types in the method name, it will flip the normal around.

        // came from above?
        if (target.velocity.normalized.y < -COS_45)
        {
            // check collision points to be all above collider's height
            for (int i = 0, c = arbiter.contactCount; i < c; ++i)
            {
                if (sourceMaxY > (arbiter.GetPoint(i).y - arbiter.GetDepth(i)))
                {
                    return(false);
                }
            }
            return(true);
        }
        return(false);
    }