示例#1
0
    // called when character is touching us with a ray
    override public bool OnCharacterTouch(APCharacterController launcher, APCharacterMotor.RayType rayType, RaycastHit2D hit,
                                          float penetration, APMaterial hitMaterial)
    {
        // ignore contacts for exploded crates
        if (IsDead())
        {
            return(false);
        }

        // check if we are touching with vertical down shift attack
        if (!m_shiftHit && launcher.IsShifting() && launcher.GetMotor().m_velocity.y < 0f)
        {
            // handle different penetration in function of ray type
            if ((rayType == APCharacterMotor.RayType.Ground && penetration < 0.1f) || (rayType != APCharacterMotor.RayType.Ground && penetration < 0f))
            {
                // defer hit (as this callback may be called for many rays)
                m_shiftHit = true;
            }
        }

        // ignore all contacts after a shift hit
        if (m_shiftHit)
        {
            return(false);
        }

        // always allow contact with crate
        return(true);
    }