Ejemplo n.º 1
0
        public virtual void CheckOnLandStatus()
        {
            var ground = IsOnGround();

            if (ground)
            {
                if (!OnGround && OnLanding != null)
                {
                    OnLanding.Invoke();
                }

                if (OnStayGround != null)
                {
                    OnStayGround.Invoke();
                }
            }
            else
            {
                if (OnGround && OnTakingoff != null)
                {
                    OnTakingoff.Invoke();
                }
            }

            OnGround = ground;
        }
 private void ManualUpdate()
 {
     if (touchedObjects.Count > 0)
     {
         OnStayGround?.Invoke();
     }
 }
    private void FixedUpdate()
    {
        Debug.DrawRay(transform.position + detectOffset, Vector3.down * detectDepth, Color.yellow);
        var        originPoint = transform.position + detectOffset;
        RaycastHit hit;

        if (Physics.Raycast(originPoint, Vector3.down, out hit, detectDepth, detectMask.value))
        {
            if (!lastGround)
            {
                OnTouchGround?.Invoke(hit.collider);
            }

            lastGround = hit.collider;

            OnStayGround?.Invoke(hit.collider);
        }
        else
        {
            OnLeaveGround?.Invoke(lastGround);
            lastGround = null;
        }
    }