@pal_trefall thank you for your terrific explanation! Not sure if you could also help with explaining something else in the Asteroids sample…
I have been working through the Asteroids sample to understand how Unity thinks about multiplayer architecture in the new DOTS stack. I understand the server being authoritative is key, but that clients still have to run certain systems to provide the immediate responses users would expect (can’t wait for the server to respond for every single thing or the lag delay will be unacceptable). I am trying to develop a better sense of how to split systems to run on either client, or server, or both. This answer is probably super obvious to anyone that knows the pitfalls of multiplayer video game development but is lost on me.
In Asteroids the systems are held in 3 folders:
/client (for systems run only on the client, like the InputSystem because only clients have input)
/server (for systems run only on the server, like the CollisionSystem because server is authoritative on collision)
/mixed (for systems that run on both client and server, like SteeringSystem because client needs instant feedback but server ultimately decides positions)
I am trying to understand why the BulletSystem is run on both client/server (/mixed) but the AsteroidSystem is run only on the server (/server).
They both seem to do the same thing: make the bullet/asteroid continue traveling the direction it was traveling by updating its position using its velocity. And they both seem to have the same level of importance for the user, knowing exactly where they are. If I shoot a bullet I would expect it to travel in a way that makes sense regardless of server behavior. I would expect Asteroids to behave the same way, in a consistent pattern because I am trying to avoid them/shoot them.
I understand the system to spawn the bullet needs to be both on the client and server (which it is, SteeringSystem is in /mixed) but once it has been created and traveling, it seems to be of the same importance of an Asteroid, no? Either both AsteroidSystem and BulletSystem should be in /mixed, or both of them should be in /server (i am using the folder location as a proxy for meaning wether the client/server should be running it).
BulletSystem
public void Execute([ReadOnly] ref Velocity velocity, ref Translation position, [ReadOnly] ref PredictedGhostComponent prediction)
{
if (!GhostPredictionSystemGroup.ShouldPredict(tick, prediction))
return;
position.Value.xy += velocity.Value * deltaTime;
}
AsteroidSystem
public void Execute([ReadOnly] ref Velocity velocity, ref Translation position, ref Rotation rotation)
{
position.Value.xy += velocity.Value * deltaTime;
rotation.Value = math.mul(rotation.Value, quaternion.RotateZ(math.radians(100 * deltaTime)));
}
As with all Ghosts the server provides SnapShot updates to all clients of both the bullet and the asteroid. Why would receiving snapshot updates from the server for Asteroids be acceptable but not Bullets? I am sure there is something very obvious I am missing.
( @timjohansson if you are out there please save me from this mental torture!)