Guidelines and best practices in Vortex simulators for user scripts in Unity

User script are an essential tool for implementing custom behaviors in Unity.

Following those guidelines will ensure that the simulation will run smoothly and will scale properly when additional screens are added.

Synchronization and Random numbers

When using Unity as a graphic renderer, especially when having several displays, it is important to properly synchronize all the displays that may be generated on different computers in a distributed simulator. Any time dependent animation or movement should not be base on the clock time (or UnityEngine.Time.time) but on the Vortex simulation time which is properly synchronized among all the computers of a distributed simulator.

Two methods are usually used.

double time = Vortex.VortexRuntime.GetSimulationTime(); // returns the current simulation time
uint frame = Vortex.VortexRuntime.GetFrame(); 			// returns the index of the current frame

By using those two methods, you ensure that the graphics effect will be synchronized with the dynamics, and all the computers will be synchronized together.

Creating DLL for scripts

VHL and user script go well together

Adding a new behavior that needs information from Vortex is done easily by creating a VHL interface that exposes the data you need. Then, create a prefab with VortexVHL component and a user script that will access and process the data from the VHL interface. More information in How to Use VHL Interface Data in Custom Unity Scripts.