I’m working on an RTS game right now, and from what I’ve read, RTS are often based on lockstep system with deterministic engines so replays and client based calculation are possible.
I know that UE4 physics is non deterministic and so my question is : What should I do to keep my game deterministic ? Is it even possible ?
I’m wondering how games like, I don’t know, World Of Tank or War Thunder would work on UE4 with tank tracks and plane physics ? Would the server run everything and send information to clients ? That sounds very heavy !
I’ve heard about not using floats as floats aren’t stored the same way everywhere, depending on your setup. But how can you have a smooth unit movement without floats ? Floats are absolutly everywhere ! Does the character MoveTo uses floats ?
From what I understand, there are 2 problems with non deterministic engines in an RTS :
Replays are impossible.
The server has to run all the physics and generates huge data traffic over network.
Let’s say replays are impossible, how would I do to keep the current game stable for everyone ? Who should run what ?
Is there any solution ? Am I wrong somewhere ? Thanks !
or simply don’t panic, and don’t use physics for RTS. you can approximate it on server by some custom collision checks (line traces), probably it can save some performance too. I do this way, but my networking stuff is not ready to give you more info.
or if you make a low scale RTS with only a few moving characters and objects, the default pathfinding/AI/movement framework should work (using floats)
@0lento demonstrated that switching to fixed time-step makes PhysX quite predictable, still not deterministic by definition but simulating the same interaction looks largely the same.
In case of WarThunder as you’ve mentioned. They use physx only for scene queries, behavior of the vehicles and tanks is driven by custom physics calculations. Most likely they don’t even use AddForce/AddTorque on their vehicles and integrate position/velocity on their own. You would want to do it for a multiplayer game anyway, to support proper replication. There is little value in WarThunder to have your planes/tanks be actual physics body as the only interaction they have is collision with each other, which won’t look good with physics anyway so you handle it manually.
Also, deterministic lockstep is a little outdated even in RTS. If optimized correctly you can send several thousand units at lowish (1Mb/s) bandwidths. Many modern RTS’s, such as Ashes of the Singularity and Planetary Annihilation are using server-client models. In fact, there is an excellent post about some of the networking in Planetary Annihilation here.
Deterministic is not outdated, more that RTS is outdated. All competitive RTS and RTS with good performance in large battles (2v2 or 4FFA) use lockstep deterministic simulation. Which basicallymeans Starcraft 1&2, and the command and conquer lineage.
The way to achieve deterministic with UE is to use it as a render engine only… Perform all consequential calculations using deterministic code and push the results into UE. There has been some headway in deterministic floats… im not sure if it’s been used in actual games. Usually they use fixed point.
Another option is “quasi determinism” with a dedicaded server to produce the source of truth and correction.
As for the games you mentioned. Nothing in world of tanks is deterministic. It is client server with server side authority and visibility checks. But it only has 32 units in the game. That breaks down when doing starcraft 2 style 2v2 with uowards of 200 units.