Esempio n. 1
0
        private void Update()
        {
            raycast.direction         = direction;
            raycast.distance          = distance;
            raycast.sphereCastRadius  = radius;
            raycast.correctSphereCast = correctSphereCast;

            detector.detectionDistance = distance;
            detector.hoverDistance     = distance;

            Debug.DrawRay(raycast.origin, raycast.direction.normalized * raycast.distance);

            RaycastHit hit;

            if (raycast.Cast(out hit))
            {
                Debug.DrawRay(hit.point, hit.normal, Color.red);
            }

            Vector3 point, normal;

            if (detector.GetGround(out point, out normal, false))
            {
                Debug.DrawRay(point, normal, Color.green);
            }
        }
        private void PrivateUpdate(float deltaTime)
        {
            //Initialize placeholder variables for surface correction, if the character is grounded
            Vector3 correctedPoint, surfaceNormal;

            //Determine if the character is grounded.
            //See ground detector for a description of the algorithm
            //  TODO, convert this algorithm to a method call, for maintainability
            if (airFreezeFrames < 0 && groundDetector.GetGround(out correctedPoint, out surfaceNormal, Grounded))
            {
                GroundUpdate(correctedPoint, surfaceNormal, deltaTime);
            }
            else
            {
                AirUpdate(deltaTime);
            }

            airFreezeFrames--;
            airFreezeFrames = Mathf.Max(airFreezeFrames, -1);
            //Debug.DrawRay(transform.position, rigidbody.velocity);
        }