예제 #1
0
    // On Dash End
    private void OnDashEnd()
    {
        // Ray to check if we are still sliding under something
        RaycastHit2D ceilingRay = Physics2D.Raycast(new Vector2(boxCollider.bounds.center.x, boxCollider.bounds.min.y),
                                                    Vector2.up, rStandBounds.height, motor.staticEnvLayerMask | motor.movingPlatformLayerMask);
        RaycastHit2D floorRay = Physics2D.Raycast(transform.position, Vector2.down, 0.05f, motor.staticEnvLayerMask | motor.movingPlatformLayerMask);

        // If ray hits environment, slide until we are out of the tunnel
        if (ceilingRay.collider != null && floorRay.collider != null)
        {
            motor.dashDuration       = 0.05f;
            motor.dashDistance       = 1;
            motor.dashEasingFunction = PC2D.EasingFunctions.Functions.Linear;
            motor.ResetDashCooldown();
            motor.Dash();
            motor.ReupdateVelocity();

            bSliding = true;

            return;
        }

        // Reset dash variables
        motor.dashEasingFunction = dashEasing;
        motor.dashDuration       = fDashTime;
        motor.dashDistance       = fDashDistance;

        // Change collision shape to match state
        if (bCrouching)
        {
            collisionShape = ePlayerCollisionShape.Crouch;
        }
        else
        {
            collisionShape = ePlayerCollisionShape.Standard;
        }

        bSliding = false;
    }