protected virtual void CheckFalling() { if (isFalling && VRTK_SharedMethods.RoundFloat(lastPlayAreaPosition.y, fallCheckPrecision) == VRTK_SharedMethods.RoundFloat(playArea.position.y, fallCheckPrecision)) { StopFall(); } }
protected virtual void CalculateLean(Vector3 startPosition, float forwardLength, float originalRayDistance) { //Cast the new down ray based on the position of the end of the forward ray but still at a flat plane of the headset forward (i.e. no headset rotation) Vector3 rayDownStartPosition = startPosition + (headset.forward * forwardLength); rayDownStartPosition = new Vector3(rayDownStartPosition.x, startPosition.y, rayDownStartPosition.z); Ray downRay = new Ray(rayDownStartPosition, -playArea.up); RaycastHit downRayCollision; //Cast a ray down from the end of the forward ray position #pragma warning disable 0618 if (VRTK_CustomRaycast.Raycast(customRaycast, downRay, out downRayCollision, layersToIgnore, Mathf.Infinity)) #pragma warning restore 0618 { //Determine the difference between the original down ray and the projected forward a bit downray float rayDownDelta = VRTK_SharedMethods.RoundFloat(originalRayDistance - downRayCollision.distance, decimalPrecision); //Determine the difference between the current play area position and the last play area position float playAreaPositionDelta = VRTK_SharedMethods.RoundFloat(Vector3.Distance(playArea.transform.position, lastPlayAreaPosition), decimalPrecision); //If the play area is not moving and the delta between the down rays is greater than 0 then you're probably walking forward over something you can stand on isMoving = (onGround && playAreaPositionDelta <= playAreaPositionThreshold && rayDownDelta > 0f ? true : isMoving); //If the item your standing over is too high to walk on top of then allow leaning over it. isLeaning = (onGround && rayDownDelta > leanYThreshold ? true : false); } }