SimulationManager::RewindToState Method

Rewinds to the provided simulation state.

Syntax

void SimulationManager::RewindToState(
SimulationState@ state,
bool resetCamera = true
)

Parameters

SimulationState@ state
The state to be restored.

bool resetCamera = true
Optional. If the camera should be reset on rewind.

Return value

None.

Remarks

The method of restoring the simulation state slightly varies depending on the Mode field of the SimulationState class. Some buffers may not be restored at all but are replaced with native game function calls.

The simulation state is obtainable through the SimulationState::SaveState method. This state can also be used to write a save state compatible file for TMInterface. Note that modifying important parts of the state invalidates the current race.

To provide state restoration across game instances, TMInterface uses memory masks to omit restoring instance specific fields such as pointers or arrays.

The method can be called in OnRunStep or OnSimulationStep calls. Note that rewinding to a state in any of these hooks will immediately simulate the next step after the hook. For example, rewinding to a state saved at race time 0, will result in the next call to OnRunStep/OnSimulationStep being at time 10. If you want to apply any immediate input state, make sure to apply it in the same physics step as the call to rewind_to_state.