private bool DetectGroundAndCheckIfGrounded(out bool isGrounded, out GroundInfo groundInfo)
        {
            bool groundDetected = groundDetector.DetectGround(out groundInfo);

            if (groundDetected)
            {
                if (groundInfo.isOnFloor && verticalSpeed < 0.1f)
                {
                    nextUngroundedTime = Time.time + timeBeforeUngrounded;
                }
            }
            else
            {
                nextUngroundedTime = -1f;
            }

            isGrounded = Time.time < nextUngroundedTime;
            return(groundDetected);
        }
Exemple #2
0
    public bool DetectLowerLedge()
    {
        // if we're paused, DONT detect
        if (IsDetectPaused)
        {
            IsDetectPaused = false;
            return(false);
        }

        if (_lowerLedgeCheckLocation != null && !IsDetectPaused)
        {
            //bool groundPresentNearFront = Physics2D.Raycast(_lowerLedgeCheckLocation.position,
            //Vector2.down, _lowerLedgeCheckRadius, _whatIsWall);
            bool groundPresentNearFront = Physics2D.OverlapCircle(_lowerLedgeCheckLocation.position,
                                                                  _lowerLedgeCheckRadius, _whatIsWall);

            _groundDetector.DetectGround();
            // if we're grounded but there's no ground shortly in front of us, it's a lower ledge
            if (_groundDetector.IsGrounded && groundPresentNearFront == false)
            {
                IsDetectingLowerLedge = true;
                return(IsDetectingLowerLedge);
            }

            else
            {
                IsDetectingLowerLedge = false;
                return(IsDetectingLowerLedge);
            }
        }
        else
        {
            Debug.LogWarning("No lower ledge check specified on: " + gameObject.name);
            return(false);
        }
    }
Exemple #3
0
 public virtual void GroundCheack()
 {
     groundDetector.DetectGround();
 }