Ways to stop a train from de-railing

What are you attempting to achieve?

  • I’m working on a train script and trying to make a system to stop de-railing

What is the issue?

  • I’m struggling to find a good method to prevent de-railing

What solutions have you tried so far?

  • I’ve tried to script collision groups and making invisible walls using collision groups but it gets very glitchy when they’re very close together.

I’m using BodyVelocity to move the train, just looking for a method to keep the train on the track at all times. (Train moves on its own so de-railing is a key no no for me)

Thank you

2 Likes

What you could try doing is above the rails, have invisible “guider” parts. They basically touch the top of the train to make sure it stays within the boundaries of the rails but don’t completely cover the sides. They could be a part on each side of the train hitting the sides at the top.

4 Likes

Thank you, I’ll try that and update you in a bit.

You can try the train being guided along prismatic constraints and switching which constraint the train is attached to at intersections.

@BuildIntoTrains

2 Likes

My head is getting dizzy reading that. Never used constraints (been learning for years and theres so MUCH i don’t know)

Do you have an example of code using constraints?

Have you tried placing an invisible collide-able part (or parts) underneath the train? Basically they will be under the train and between the tracks and will collide with the tracks to prevent the train from de-railing.

Yes but for some reason the train keeps wanting to move to the right and ends up de-railing.

If you don’t want the trains to be able to derail why aren’t you just CFraming it ?

2 Likes