Esempio n. 1
0
        public void DetectGround()
        {
            _groundHitInfo = new GroundHit
            {
                groundPoint   = transform.position,
                groundNormal  = transform.up,
                surfaceNormal = transform.up
            };

            ComputeGroundHit(transform.position, transform.rotation, ref _groundHitInfo, castDistance);
        }
Esempio n. 2
0
        private void FixedUpdate()
        {
            _groundHitInfo = new GroundHit
            {
                groundPoint   = transform.position,
                groundNormal  = transform.up,
                surfaceNormal = transform.up
            };

            ComputeGroundHit(transform.position, transform.rotation, ref _groundHitInfo, castDistance);

            text.text = isOnGround.ToString();
        }
Esempio n. 3
0
        public bool ComputeGroundHit(Vector3 position, Quaternion rotation, ref GroundHit groundHitInfo,
                                     float distance = Mathf.Infinity)
        {
            RaycastHit hitInfo;

            if (BottomSphereCast(position, rotation, out hitInfo, distance) &&
                Vector3.Angle(hitInfo.normal, rotation * Vector3.up) < 89.0f)
            {
                groundHitInfo.SetFrom(hitInfo);
                groundHitInfo.surfaceNormal = hitInfo.normal;
                groundHitInfo.isOnGround    = true;

                return(true);
            }
            else
            {
                return(false);
            }
        }