So I have a vehicle which uses Simple Wheeled Vehicle Movement Component. Now I wanted to add multiplayer support and found some issues. First of all, unlike the default 4W Vehicle Movement Component, you can’t just set replicate movement checkbox to actually replicate movement. You need to make a couple of custom events and for example, call the first event on the server, then from the server call multicast event which will actually execute SetDriverTorque method in order to move forward in multiplayer. But even if it works, the movement has extreme jittering and lags. I also tried the default 4W Vehicle Movement Component, but it also has lags and jittering and it doesn’t support N-wheeled vehicles, so I can’t use it for my purposes. Maybe I’m doing something wrong? Or maybe I have to write custom physics and replication in order to move vehicle smoothly?
Did you ever get anywhere with this? I’m also experiencing lag and jittering using the same method.
The only real way is to make your own non physical system with replication.
You can try to replicate physycs, but you will get often drastically different results across clients.
If you are really set on simulating, assume one client is in charge of simulating - say the one that possesed the car.
Then replicate the behaviour of the vehicle to other clients based on what that specific client does.
There will be lag on this, so its not ideal for shooters or other things where you expect a target to be seen where it is (Then again thats the principle negative of all replication).
The common work around is to let the other client take over on the shot and compute results based on what that client was seeing.
Often resulting on the driver being ■■■■■■ for being shot out of nowhere…
An acceptable compromise is to speed up a sync by sending less data.
Say you were to only transfer the position and rotation(forward vector) of the vehicle, and its speed.
And update those every tick.
Youd have less computation and data being sent over as opposed to sending a bunch of values for physical forces, and various car components like the shocks/wheels etc.
The car on the non primary client will look a bit odd while moving - maybe - but the speed of transfer is normally enough that you wouldn’t necessarily notice the lag with most setups.
While making your own and therefore understaing how things are to be done is always a better idea…
If you aren’t savy enough to make your own replication system, I would suggest looking into the marketplace for vehicle specific (note that it if you want physics, it should be PhysX based, not Chaos unless you want issues) replicated system.
Theres lots of stuff, some even replicates vehicle mesh damage.
Creating a physics-less system with 4 wheels is also somewhat trivial.
Run a trace from where the wheel should be to the floor, adjust the position/rotation of the body based on the 4 results.
Remeber that you need to trace ahead of the car in terms of speed.
You want “this” trace to match where the car is going to be the “next” frame.
With that you could shove it all in a character class and use the built in position replication. Its not ideal ofc. But it “works” out the door.