I have a railroad crossing gate, it contains a cylindrical constraint, which is controlled by a server script. The network owner of the gate is the sever. When the server script updates the target angle for the cylindrical constraint the gate’s movement is not replicated as expected to the client.
The issue:
This is how the gate’s movement is coded in the server script:
--when train comes lower the gate
boomarm.Functional.Motor.CylindricalConstraint.TargetAngle = boomarm.Functional.Motor.CylindricalConstraint.LowerAngle;
--when train leaves raise the gate
boomarm.Functional.Motor.CylindricalConstraint.TargetAngle = boomarm.Functional.Motor.CylindricalConstraint.UpperAngle;
Here is the game which this issue occurs in:
A few things to note:
The video is recorded in studio to showcase the different between the server and the client but the same does occur in a live game.
This issue seems to apply to other constraints as well, having the server move the gate with an AngularVelocity, LinearVelocity, LineForce, or a VectorForce all reproduce the same issue.
Touching the gate will update the gate’s position to where it should be, but sometimes you have to stay touching the gate for a little bit before it updates.
Giving network ownership of the gate to the client/player does fix the gate’s movement and resolve the issue, however, since network ownership can’t be given to multiple players at once this only works for single-player games which my game is not.
I am enrolled in the beta channel and have all the beta features activated.
These are the solutions I’ve tried:
Changing workspace.PhysicsSteppingMethod to Adaptive and Fixed
Changing workspace.InterpolationThrottling to Enabled and Disabled
Having a different constraint move the gate (see notes above)
Changing the ServoMaxTorque of the cylindrical constraint in the gate every frame to keep the gate awake (see this post)
I’ve been at this all morning and afternoon so before I go cry in a corner or something I’d like some feedback or potential solutions on top of what I’ve tried already.
Part of the issue that I see is that you have limits enabled for the slider, but actuator type is none. Try disabling that. Basically, you have enabled an option for something that you are not using. With none selected, it might be confusing the engine.
Something else you might try is setting ServoMaxTorque to math.huge on the command line. It will show as inf in the field.
I would clone the part localy for each player, physics should be handled localy in most case (tell me if i’m wrong). Otherway you can script the rotation without physics
Constraints may need to have their NetworkOwnership set to the Server with the script, otherwise you can get physics lag (physics Constraints stutter or stop).
Why not Anchor it and CFrame the gate movement so it doesn’t have any lag issues because that’s done on the Server?
And why the heck are you using a CylindricalConstraint? A HingeConstraint does the correct job without the added physics of the slider.
CFrame could cause the gate to clip through a car or something else that’s under the gate. I’ll replace the cylindrical constraints with hinge constraints and I will get back to you on that.
The hinge constraints didn’t resolve the issue, but I will still use them over the cylindrical constraints since they are simpler. I think Tween would have the same problem as CFrame but I’ll look into it after I try Temateite’s suggestion.
I did some more experimenting and the server registers everything as expected but the client is very behind. Here are a couple new videos showcasing the issue:
Client:
Server:
In a live game the gates don’t update unless you’re literally standing on them. I get the feeling this is an engine bug. Surely the server can’t be on its knees with only 1 player, 2 hinge constraints, and 14 vector forces??? (vector forces are for train movement)
The only anchored Part that’s tweened is the rotating hinge Part you weld everything else to.
The other gate Parts would be unanchored and welded to the tweened Part.
In your video examples what is are the gates NetworkOwnership set to?