Multiple Simulations #179
-
Is it possible to run multiple simulations for different clients at once? I'm working on a multiplayer game and I will run into a situation where Client A and Client B will be in two different 'levels'. For example if Client A is playing the car demo and Client B is playing the tank demo, will I be able to run each 'level' as a different simulation without them causing issues for each other? If this is possible what would be the best way to go about it? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yup- nothing fancy about it, there's no shared state in the background. Just create separate simulations. To use the demos as an example, this works just fine: NewtDemo newtDemo = new();
RagdollDemo ragdollDemo = new();
ColosseumDemo colosseumDemo = new();
newtDemo.Initialize(content, camera);
ragdollDemo.Initialize(content, camera);
colosseumDemo.Initialize(content, camera);
for (int i = 0; i < 100; ++i)
{
newtDemo.Update(window, camera, null, 1 / 60f);
ragdollDemo.Update(window, camera, null, 1 / 60f);
colosseumDemo.Update(window, camera, null, 1 / 60f);
}
newtDemo.Dispose();
ragdollDemo.Dispose();
colosseumDemo.Dispose(); If you intend to run them on multiple threads simultaneously, make sure you don't give them any state to share, like buffer pools or thread dispatchers. |
Beta Was this translation helpful? Give feedback.
Yup- nothing fancy about it, there's no shared state in the background. Just create separate simulations.
To use the demos as an example, this works just fine:
If you intend to run them on multiple threads simult…