I have a train movement system which is controlled by the player. It depends on linear velocity to move with calculations made within the scripts based on the throttle input (W to increase throttle, S to decrease throttle, A to increase brake, D to decrease brake).
The train occasionally starts shaking when it’s stationary, however the actual bug begins when it starts moving. Upon increasing the throttle the train begins shaking a lot and in same instances it will fly off the rails.
After debugging I have noticed that the constraint I used to connect the two carriages together (Rod constraint) was causing the issue. Disabling the rod constraint appeared to make an improvement in terms of how much the train shaked. I also learnt that changing the densities on different parts of the train effected this issue.
Train shaking on the track with the rod constraint enabled:
Train shaking on the track with the rod constraint disabled: (Some shaking is visible but it isn’t that bad, and I would not use this as my solution because I need a way to connect the two carriages together)
Debugging methods I used and results:
- The train was 30k studs away from 0,0,0 because of map size so I tested the behaviour of the train near 0,0,0 and it did not make a difference
- Disabling the rod constraint, this led to the train not shaking as much but it showed some shaking with the bogies/axels and the shaking was worse on curves.
- Deleting any visual models and leaving the important parts of the driving system like the gliders (keeping the train on the rails because I don’t use the actual wheel models themselves). This also led to no change in the bug.
- Making everything in the train model the same density, this seemed to show some effect on the shaking and glitching but it did not fix it. This is how I knew it was causing the bug.
- Trying out different gliders, I suspected my gliders could be the issue so I enabled
AreContactPointsShown
and It seemed like the bogies were jittering side to side a lot no matter what design I came up with. - Deleting the track and letting the train travel on the grass, the train behaved differently when the rod constraint was enabled and disabled in this instance. When it was enabled the train started jumping.
Rod constraint enabled:
Rod constraint disabled:
Other notes:
This bug wasn’t happening before it started happening around November. I literally went to bed and the train system was working absolutely fine. Then the next morning I wake up with a surprise that my entire train shakes when it moves.
System Information:
Intel(R) Pentium(R) CPU 4417U 2.30GHz
12 GB RAM
Intel(R) HD Graphics 610
Expected behavior
To increase the throttle and the train smoothly making its way along the track with no visible shaking or glitching.
A private message is associated with this bug report