public void RewindSomeFrames(int frames = 1) { FrameInfo frame = null; for (int i = 0; i < _rewindMultiplier * frames; i++) { if (_frames.Count > 0) { frame = _frames.Pop(); } } if (frame != null) { GetComponent <Transform>().SetPositionAndRotation(frame.PlayerPosition, frame.PlayerRotation); _player.GetComponent <RigidBody>().position = frame.PlayerPosition; _player.GetComponent <RigidBody>().velocity = frame.PlayerVelocity; if (frame.CurrentCheckpoint != _currentCheckpoint) { _currentCheckpoint = frame.CurrentCheckpoint; EnableCheckpoint(_currentCheckpoint); } Score = Score + (frame.ScoreDiff * ScoreRewindMultiplier); } }
void OnEnable() { _player = GameObject.FindWithTag("PlayerBody").GetComponent <BangsPhysics.RigidBody>(); _gameState = _player.GetComponent <GameState>(); }