Question About Trains

DainBramages

New member
The "Moving Platform" script will move a platform along waypoints. Yeah, that works. The page that talks about it says you can move trains that way. "The moving platforms are a generic term meaning any object that can be moved/rotated within the scene. This includes elevators, trains, revolving doors, etc."
When I set up a train with multiple cars, they move like a log. The engine stays on the tracks (follows the waypoint gameobject position and rotation) but the rest of the train cars stick out like a stiff tail on the turns. It moves like a big turd guided by the train engine. I've tried a bunch of different settings to get the cars to follow the waypoints as well, even giving each car its own script. Maybe I did something wrong?
I examined the train in the demo but it doesn't use waypoints. In the demo, the "train" has an animation that is basically ALL of the movement around the tracks. It is flying around and the tracks just happen to be there. It doesn't use the moving platform script to move on waypoints. So the demo "train" is just an animation set next to tracks which is really misleading when you first see it. I could script a train animation on my own without paying $125 for extra confusion and time.
I guess I'm wondering if it is possible to move multiple train cars with the moving platform waypoints or if I should just animate it and be disappointed? If it can be done, I'll invest more time in figuring out what I'm doing wrong.
 
The generic moving platform term is for any type of moving object, including trains, vehicles, elevators, and actual moving platforms as you'd see in a platformer. The MovingPlatform component is a waypoint based mover so unless your train is going straight it isn't the best use case for actual trains.

The asset is focused on being a great character controller so it does not include a train controller and in the demo scene as you noticed we just used an animation to represent the train. An alternative to the animator is to use splines for the train and similar to the train the demo the character will be able to follow that spline.
 
Thank you for the prompt response. And that's what I kind of figured.
The moving platform script for one object works great even while turning and is very simple to set up complicated pathing. I had just hoped for something magical I had overlooked regarding multiple objects. I'll look into splines. Again, thank you for the response.
 
Right after I read your response, it took me about five minutes to get the Synty assets demo train to work with moving platforms. Since one moving object worked great, I just made each train car a separate moving object with the same "moving object" script values. Adjusting the waypoints more will get smoother turns. And once the track completely loops it should transition from the beginning okay. There might be some issue I haven't found yet but so far looks acceptable and the effort of (successfully) doing it was very minimal.
(I placed an inactive copy of the moving platform script on the train engine model itself so I could get a gizmo of the train at each waypoint and adjust the rotation more easily. You can see it in the clip)
 
Top