Negative train speed isnt synced/ is synced as positive speed

Trains don’t sync their speed properly when their speed is set to a negative value via SetTrainSpeed/SetTrainCruiseSpeed.

For the entity-owner it drives backwards fine, but for everyone else it drives at a positive speed causing the train to teleport/jitter.

RegisterCommand('train', function(source, args, rawCommand)
    local model = `metrotrain`
    repeat
        RequestModel(model)
        Wait(100)
    until HasModelLoaded(model)
    local train = CreateMissionTrain(25, -273.8497, -1217.7427, 37.5472, 0) --(below b2372: change param 1 from 25 to 24)
    SetTrainSpeed(train, -10.0)
    SetTrainCruiseSpeed(train, -10.0)
end)

Second Entity Owner:

First Entity Owner:

1 Like

Just a thought: have you tried to send the information to the server and letting the server handle sending that information back to all clients?

So once you want the train to go backwards, trigger a server event and allow the server to trigger a client event to everyone and see what happens to the train that way.

1 Like

Gentle push on this.
Being able to drive trains backwards would enable the usage of trains for interesting things such as elevators and cablecars.

Also this should probably be moved to Platform Suggestions as trains are not synced properly driving backwards with onesync off/native R* sync.

If its impossible feel free to close.

The direction a train travels is established in CREATE_MISSION_TRAIN (required for initializing the engine bits, etc) and speed is relative to the direction. Supplying a negative speed breaks the physics (not synchronization); “negative speeds” generally don’t exist.

Have you experimented w/ the isPingPongTrack field in traintracks.xml? There are places in gamecode where the assembly somewhat matches your desired functionality. Although, it is hard to be certain about without testing.

1 Like

Thank you very much for looking at this!
I have tried isPingPongTrack, unfortunately it flips the whole model around 180° instead of just driving backwards.
When it happens there is also a good chance when you stand unattached in the carriage you get thrown out of it. I tried this with the native cable-car trains as they would benefit from this the most.

Out of curiosity, how come on the entity host client the train at least “looks to be” driving backwards/at negative speed correctly?

I am still stuck on this.
Any chance of a re-visit?

Maybe a native to change the trains direction after initialization?

I am also still curious why even though negative speed breaks physics, it looks fine on the entity-owners client?