Right now I have a vehicle framework that has been working mostly fine since I made it. Initially, I had split friction into two types, static and dynamic so that I could handle friction differently when the vehicle is very slow or stationary so friction doesn’t cause it to jitter but I have not been able to prevent that from happening using normal “VectorForce” constraints so I decided I’d use a “LinearVelocity” constraint and set the max force property to the calculated static friction in that moment of time. It worked fine until I noticed it was not replicating anymore when a player takes ownership of a vehicle.
Here’s a video demonstrating the lack of replication with network ownership overlay enabled: (video is sped up 3x for watching convenience)
now as you can see in the video as I get close to the vehicle it doesn’t turn red (I have no idea what red means) but when I ride it, it correctly turns green which means I have network ownership of the vehicle. I handle network ownership of vehicles manually in my scripts that’s why it doesn’t turn green like other parts when I get close. You can also notice that when I drive away and get off the vehicle it teleports back to where it was. Later in the video, you can see that when I switch from client to server view the vehicle didn’t move at all for the server even though the client has network ownership of the vehicle and has moved it.
this is the bit of code where I create the constraint.
If I comment it and all other references to it and test again,
everything works fine as it should, except now my vehicles can’t be stationary because there is no static friction in the process as you can see in this video: (video is also sped up)
Is the problem with my code structure and more code context is needed for a solution?
I doubt that is the case since simply removing the linear velocity constraint fixes the replication issue. If the problem was with the structure of my code it should have persisted I would argue. If there is context I would assume to be relevant it would be that the vehicle code is split into server, client, and common modules, this bit of code shown in the screenshots is in the common module which is loaded by both the client and the server and is switched on and off by the client or the server depending on who is simulating the vehicle.
Do I have to use a linear velocity constraint as a solution for static friction?
No, if you have no idea what is causing a replication issue either and instead have an alternative solution to friction with near-zero velocities I will be more than happy to use that and replace the linear velocity code, I just want it to work, the primary issue here is friction in near zero velocities.
How does the vehicle work anyway
In general, it’s like a hovercraft with vector forces as suspension and vector forces acting on ground level on a per-wheel basis to simulate friction based on velocity direction and pressure from the suspension. So without simulating friction, the vehicle would slide around as I don’t let Roblox handle it for me. So no, making the wheels can collide or increasing their friction coefficients in custom properties won’t change anything. The wheels are for decoration anyway and cannot be attached with physical simulation without ruining the entire thing