How to get information about the Vortex simulation
When creating special behaviors using C# scripts, it often necessary to obtain timing and other information about the state of the Vortex simulation.
It is vital, especially for a distributed simulator, to rely on Vortex timing information instead of Unity timing. Each computer in a distributed simulator has its copy of the Unity application that was created, and each of these applications can have slightly different timing information. By accessing Vortex timing information, you ensure that all Unity applications will have a common time base, and display coming from those applications will be synchronized.
VortexApplication singleton
Information about the current simulation can be retrieved by using VortexApplication main. It can be accessed as a singleton, which is valid when the Vortex Application is running.
Properties
Instance | Give access to the current VortexApplication object. It can be used to test if the Vortex Application is created. | if (Vortex.VortexApplication.Instance == null)
{
Debug.LogError("Vortex Application is not running")
} |
SimulationTime | Returns the current simulation time in seconds | private void FixedUpdate()
{
double timeIncrement = Vortex.VortexApplication.Instance.SimulationTime - previousTime;
playableDirector.time += timeIncrement;
previousTime = VortexApplication.Instance.SimulationTime;
} |
SimulationTimeStep | Returns the simulation time step in seconds. This is how much time is increased at every update, the inverse of the frame rate. | private void FixedUpdate()
{
// this assumes that Vortex and Unity is absolutely in sync, which may not be the case in a distributed simulator
elapsedTime += Vortex.VortexApplication.Instance.SimulationTimeStep;
} |
FrameIndex | Returns the current frame index. It is increased by one at each Update() of the simulation. | |
IsPaused | Determines whether the simulation is actually paused | |
IsMaster | Determines if the current Vortex application is the master | |
SelectedLanguage | Returns the currently selected language and country code (LL_CC), or an empty string if no locale was selected. This functionality requires a ConsoleModule properly configured. Â | |
CurrentApplicationMode | Returns the current application mode for Vortex. Possible values are Vortex.ApplicationMode.Editing : Vortex is loading assets and preparing the content for simulation. Vortex.ApplicationMode.Simulating : Vortex is simulating Vortex.ApplicationMode.Playback : Vortex is playing back a recorded simulation. |
Public Methods
Â
Changes the application mode asynchronously. The application mode will change when possible by default. It is possible to wait for the mode to actually change by using the waitForModeToBeApplied parameter. Returns True if the requested application mode is valid in the current context. | |
Sets the ApplicationMode to Simulation | |
Sets the ApplicationMode to Editing | |
Pauses the simulation. It will be effective at the next application update. | |
Makes the simulation do one step and then pause.VC | |
Translate the given text, with the given context. This functionality requires a ConsoleModule or s SimulatorModule properly configured. |
Public Event
Notifies when the ApplicationModue is changing. The event is received with the old and the new application mode. |
Â