Download

Working on a train, strange issue with wheels, can anyone advise?

Hi everyone.

I’ve been working on a train/track system, which has been going very slowly and causing stress, but has nevertheless been quite a fun endeavour.

It works… sort of… but experiences a weird bug where the wheels start to twitch, eventually causing the train to bounce up and derail.

The engine consists of a static mesh (the main body of the engine) and a number of wheels, guides and constraints.

Each pair of wheels is parented to an axle, which is attached by physics constraint to a guide, (axle and guide are hidden in game) such that it can rotate about its axis freely, allowing the wheels to turn. The guide is constrained to the main body, such that it can swivel slightly around the z axis, allowing them to take corners easier, and such that it can slide slightly from side to side under the train, to help all wheels to stay on the rails as it takes the corner.

At the front and rear axle there is also a collision component which overlaps with the tracks (a spline mesh) and sets the location and rotation of the front and rear guide, to help guide the train. In fact the current set up of train and rails works even with this feature turned off, as the wheels are able to guide the train quite well by physics alone.

At the moment the wheels have a physics material that has 0 friction, so they don’t actually turn.

Propulsion is currently achieved by a physics thruster component placed between the middle wheels.

Here are some screenshots, taken from beneath the carriage, which shows the constraints of the guides and axles, and soon to follow will be a link to a youtube video (currently taking its time uploading!) of the train running on the track and experiencing the strange jumping bug, though not actually derailing itself. The bug presents itself even if the guides are fully constrained with no allowed movement, even if the wheels are prevented from rotating (they are frictionless) and with the train aligning itself by spline or not.

There are no bumps in the collision mesh for the track (in the video the visual mesh is identical to the collision mesh). The wheels are tapered towards the hub as on real rail wheels (try saying that 3 times fast!).

Can anyone offer any advice as to what could be causing this? I also noticed in earlier experiments that even with physics fully constrained, the components would sometimes rotate or slide about a little, is there anything I could be missing? I realise that these screenshots may not be enough, so I am happy to take more screenshots of anything anyone needs to see, or record further videos.

Undercarriage.jpg
The above screenshot shows the undercarriage of the train. The cubes are the guides (or the axles, they are identical cubes in identical locations with all collision disabled).
UndercarriageGuideConstraints.jpg
The above screenshot shows the constraint settings between the rear guide cube and the main body. All other guide constraints are identical.UndercarriageAxleConstraints.jpg
This final screenshot shows the constraint settings between the rear axle and rear guide. All other axle constraints are identical.

Finally, this video shows (from underneath the train) the engine running on a stretched s-shape track, including the weird wheel twitching bug. At the time of recording all constraints were locked except the axles rotating. The train doesn’t manage to jump free from the track, but you can see the problem cropping up, anyway.
https://youtube.com/watch?v=8BiylzyQ6Ho

[Edited to add video].

Physics can always get funky in these kinds of elaborate schemes. The thruster seems weird but maybe it will actually make things easier to test the wheel play. I’d suggest messing with the gravity settings, the mass scale, and even try motored wheels in place of thrusters (or reposition the thruster to angle downwards?). Good luck.

I tried I with a wheel driven engine, the only reason it currently uses the thruster is because the wheels are currently frictionless. When they were frictional (is that even a word?) the flanges got stuck on the rails. I did try replacing the wheels with separate flanges, having them frictionless and tried driving from the wheels, but then I got extra bumpiness because the wheels aren’t perfectly round. And I still had twitchy wheels.

I had to lower the mass of the engine to stop the engine leaning despite the constraints, but if I lower it too much it obviously has too little mass.

I don’t want to have to create my own constraints system!

Have you tried adding or adjusting the linear damping?

Thanks for the suggestion. I haven’t played with the damping, partly because I’m not entirely sure of what it does and how it differs from stiffness, but also because at the moment the linear constraints are locked. This can be seen in the video (just added to the original message), in fact, when the train turns the first corner the front wheels don’t quite follow the track because they aren’t allowed any lateral movement right now.

I am hoping that the problem is caused by my less than stellar knowledge of how the constraints system works and what the features do, but I’ve had trouble finding a good guide for the constraint components.

[Edit:] I’ve just realised you might have meant the linear damping under the physics tab on the actual wheels/axles rather than the linear limits tab on the physics constraint. Wouldn’t that effectively add excessive drag to the train?

An update: I have played with the linear and angular stiffness and damping in the constraints, and it has not made things any better. Has anyone any experience of physics driven vehicles had anything similar at all?

The problem also occurs on perfectly straight track, and in fact without any track at all! (Started the train without any track, and even without moving something was causing the train to jitter).