protected virtual void RewindPosition() { if (CanRewind()) { isRewinding = true; Vector3 rewindDirection = lastGoodHeadsetPosition - headset.position; float rewindDistance = Vector2.Distance(new Vector2(headset.position.x, headset.position.z), new Vector2(lastGoodHeadsetPosition.x, lastGoodHeadsetPosition.z)); playArea.Translate(rewindDirection.normalized * (rewindDistance + pushbackDistance)); playArea.position = new Vector3(playArea.position.x, lastGoodStandingPosition.y, playArea.position.z); if (bodyPhysics != null) { bodyPhysics.ResetVelocities(); } } }
/// <summary> /// The RewindPosition method resets the play area position to the last known good position of the play area. /// </summary> public virtual void RewindPosition() { if (lastGoodStandingPosition != null && headset != null) { Vector3 storedPosition = playArea.position; Vector3 resetVector = lastGoodHeadsetPosition - headset.position; Vector3 moveOffset = resetVector.normalized * pushbackDistance; playArea.position += resetVector + moveOffset; if (bodyPhysics != null) { bodyPhysics.ResetVelocities(); } OnPositionRewindToSafe(SetEventPayload(storedPosition)); } }
protected virtual void RewindPosition() { if (!isRewinding && playArea != null & lastGoodPositionSet && headset.localPosition.y > crouchRewindThreshold && BodyCollisionsEnabled()) { isRewinding = true; Vector3 rewindDirection = lastGoodHeadsetPosition - headset.position; float rewindDistance = Vector2.Distance(new Vector2(headset.position.x, headset.position.z), new Vector2(lastGoodHeadsetPosition.x, lastGoodHeadsetPosition.z)); playArea.Translate(rewindDirection.normalized * (rewindDistance + pushbackDistance)); playArea.position = new Vector3(playArea.position.x, lastGoodStandingPosition.y, playArea.position.z); if (bodyPhysics != null) { bodyPhysics.ResetVelocities(); } } }