Example #1
0
            private void SetFootToPlane(Vector3 planeNormal, Vector3 planePoint, Vector3 heelHitPoint)
            {
                planeNormal      = this.RotateNormal(planeNormal);
                this.toHitNormal = Quaternion.FromToRotation(this.up, planeNormal);
                Vector3 hitPoint = V3Tools.LineToPlane(this.transform.position + this.up * this.grounding.maxStep, -this.up, planeNormal, planePoint);

                this.heightFromGround = this.GetHeightFromGround(hitPoint);
                float heightFromGround = this.GetHeightFromGround(heelHitPoint);

                this.heightFromGround = Mathf.Clamp(this.heightFromGround, float.NegativeInfinity, heightFromGround);
            }
Example #2
0
            // Set foot height from ground relative to a plane
            private void SetFootToPlane(Vector3 planeNormal, Vector3 planePoint, Vector3 heelHitPoint)
            {
                planeNormal = RotateNormal(planeNormal);
                toHitNormal = Quaternion.FromToRotation(up, planeNormal);

                Vector3 pointOnPlane = V3Tools.LineToPlane(transform.position + up * grounding.maxStep, -up, planeNormal, planePoint);

                // Get the height offset of the point on the plane
                heightFromGround = GetHeightFromGround(pointOnPlane);

                // Making sure the heel doesn't penetrate the ground
                float heelHeight = GetHeightFromGround(heelHitPoint);

                heightFromGround = Mathf.Clamp(heightFromGround, -Mathf.Infinity, heelHeight);
            }