// 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); }
// called when character is touching us with a ray // - motor : character controller touching the hitable // - rayType : type of ray detecting the hit // - hit : hit info // - penetration : penetration distance (from player box surface to hit point, can be negative) // - hitMaterial : material of hit collided (can be null) // - return false if contact should be ignored by engine, true otherwise virtual public bool OnCharacterTouch(APCharacterController launcher, APCharacterMotor.RayType rayType, RaycastHit2D hit, float penetration, APMaterial hitMaterial) { return(true); }