I’m Awesome_0A and I’ve been scripting for a long time now. I mostly specialise in general scripting so you’d think I’d be good at this but my brain is just not ready to script today so I made this post to ask for assistance from the community.
My issue is that I am unsure of what method to use to make a train (model) follow a specific pre-set track. The track will have turns and straights so the train has to be able to adapt to that and stay on the track. I was thinking about using Vector3 and checking if the trains wheels are colliding with a track and if so move forward 1 stud in the direction of the track and repeat but I can think of a million issues using this method.
I was actually wondering the same thing, since I will need to make a pushable cart in my game follow a certain path. Tween Service is definitely not an option, because for a path with lots of turns you would have to create tons of tweens and unnecessary path nodes. I havent come up with a solution yet. If someone offers a good solution, tag me
Please try that Search tool up top. There have been a lot of posts about trains, some using physics Constraints, and others using CFraming.
I’ve used a simple setup that allows the train wheels to ride on the tracks with HingeConstraints. I made it as a training aid for another person in this post: How to make a basic train - #12 by Scottifly
If you need the bogeys to pivot then you can put 2 axles on the bogey, hinge it at the center, and put 2 of the red inner alignment wheels at either end of the bogey.
The tutorial is great and all but I would need to weld everything together and this train model easily has over 5000 parts. What would you recommend doing to counter this problem? I don’t really look forward to spending 12 hours making welds.
It can for sure give you a lot of trouble performance wise, moving 5000 parts around all the time.
Imagine the parts being LEGO bricks. It will for sure cause more lag having a train made out of individual LEGO bricks, than having it molded into one.
As stated by others, you can build the train with Anchored Parts and a simple weld script that welds the parts and unanchors the parts. The only issue is the time it takes can lag a place loading if you have a lot of Parts and it has to weld every time it’s made.
If the train was given to you to script you can tell the builder that it needs to be cleaned up to reduce Parts, or that they need to weld it together. If they gave you an incomplete model that is their issue, not yours. @TortenSkjold it already looks like it’s made of Meshparts.
You said the entire model is 5000+ Parts, but is that the entire train, or just the engine? If the builder made the complete train with an engine and 10 identical cars they only need to weld the engine and 1 car and then copy/paste that in place of the other cars. As TortenSkjold said, moving that many Parts is going to cause problems.
I wasn’t referring to that he didn’t already use MeshParts, I suggested that he went into Blender. Because the train is surely made out of too many parts.
I have found that if you select a bunch of parts in explorer and then weld, they will all weld together in one shot. 5k parts is a lot, and that’s not going to help with performance, especially when there’s scenery stuff to consider. You could try reducing the parts count by making unions.
I haven’t watched the tutorial, but from what I have seen of those cart riding games, there’s two parts that stick down from the cart that sits between the tracks on the inside. Then I believe you can use a constant force to move it.
The easiest way to weld multiple parts together without any plugins is the following:
Select all parts within the model. If you want to multi-select, click the part closest to the top of the model, hold shift, then click the part at the bottom of the model. Or, right click the model, and click “Select Children”
From here, you can simply click the arrow underneath the “Create” button (found in the model tab) and click on “Weld”