public RewindState(float seconds, HitboxBody ignore = null) { IgnoreBody = ignore; var lerpFrame = WorldFrame - seconds / Time.fixedDeltaTime; Frame = Mathf.FloorToInt(lerpFrame); Frame2 = Mathf.CeilToInt(lerpFrame); LerpVal = lerpFrame - Frame; Lerp = true; if (LerpVal <= TimeErrorMargin) { Lerp = false; } if (LerpVal >= 1 - TimeErrorMargin) { Frame = Frame2; Lerp = false; } Valid = (Lerp ? IsLerpRewindValid(lerpFrame) : IsFrameRewindValid(Frame)) && !IsWorldRewound; if (Valid) { BeginRewind(this); } else { Debug.LogError($"Error Rewinding. {nameof(WorldFrame)}: {WorldFrame}, {this}"); } }
public RewindState(int frame, HitboxBody ignore = null) { IgnoreBody = ignore; Frame = frame; Lerp = false; Frame2 = frame; LerpVal = 0f; Valid = IsFrameRewindValid(frame) && !IsWorldRewound; if (Valid) { BeginRewind(this); } else { Debug.LogError($"Error Rewinding. {nameof(WorldFrame)}: {WorldFrame}, {this}"); } }