I recently built a car system using the roblox contraints, and it works perfectly in studio test mode, however in-game there is a delay between the player pressing a key and the event firing (the car turning or accelerating). I am just wondering if there is an easy way around this to make it look instant for the player, but still look smooth on the server at the same time?
You could try setting the network owner of the car to the player, other than that without knowing how you handled your system I’d say see if you can decrease the serverlag in the first place.
In this case, you will have to set the
NetworkOwnership of the car to the player to simulate the physics through their machine and not server.
There might be other factors of the system, such as input.
Dang it, I was typing and someone beat me to it.
Thank you guys! I’ll try this and see if it helps.
Have the client have NetworkOwnership.
This way, the client can replicate the movement directly to the server, instead of a round trip.
How could I make the input more instant?
The vehicle seat comes with its own throttle system built in. (Controls are near instant when I use them) Try using those to handle your Body movers.
Nothing is really instantaneous, however setting the network ownership of the car to the client using it is your best bet. For example, characters - you see how their input is “instantaneous”, right? If you do the same for the car, you should see the same result.
By other factors, those are references to issues such as validation. Given that a player can replicate physics with anything they network own, you’ll also need to ensure they aren’t effectively “teleporting” the car around.
I would try using that but it makes it very difficult to make it mobile compatible. I have found making custom controls is easier for cross-platform integration.
How would I set the network ownership? I have a model with multiple parts including wheels attached to a main body with constraints. I have tried t set the network ownership of the wheels but it won’t let me. It will let me set it for the main body though - does this set it for all of the parts? (the lag problem still persists after trying this)
You set network ownership by calling SetNetworkOwner on a BasePart. You must either set the root of the assembly or all the parts - either works. Network ownership does not work for anchored parts.
I have set the network ownership for the root of the assembly, but the lag problem still persists. I tried to set it for all the parts but it comes up with an error saying I can’t set it for anchored parts, even though not one of the parts in the assembly is anchored.
I have managed to set the network ownership to each part in the chassis, and the reaction time is now instant so thank you!! But the lag problem still persists. The cars lag randomly but nothing else does and I have no idea what the cause is.