Animating a train along a track

I’m building a subway train that will move from station to station, stop at each, and let people on and off. Right now I’m using a matinee in level blueprints to animate it through the tunnels. The problem is getting it to line up with the tracks. It is extremely tedious trying to animate using matinee and keeping the wheels in line with the tracks. I thought about doing the animation in blender and importing that with the train, but the tunnel is made from a spline and I don’t see a way of exporting the tunnel in the shape it is to get the reference for animation. What I would normally do is merge the actors in the editor into one mesh then export that from the content browser into Blender, but because the tunnel is a spline, using the merge option under the right click menu merges them but re-orientates each mesh so they no longer line up.

I’ve seen the roller coaster plugin by Teddy0k and thought about using that, but it would seem the default pawn and player controller need to be switched, and the player looses control of the character while in motion. Ideally I just want a train moving through the subway that a player can get on or off at will and continue moving through the world.

Ultimately I’d like to be able to have 2 or 3 cars attached end to end so the train can bend around turns, but first things first.

I’m just looking for a better method of animating this then matinee, if there is one. Any suggestions would be appreciated. I’m not ruling out Teddy’s yet either, just doesn’t seem like the best option for this.

Maybe we’ll just say its the future and the train is a hover train… :wink:

Don’t think that fits with the game though.

Well, you certainly have your work cut out for you. I have trains going about my map dropping off passengers, but I used timelines to achieve it all. Therefore, all my tracks were created so that they could be represented by mathematical functions.

How rigid is your spline structure?

The spline is not to rigid and doesn’t need this exact shape. There’s nothing outside of the subway so I can move it if needed. I’m just trying to make the whole tunnel system from one small mesh so there’s only a small piece in the content browser, hence the spline instead of making the full tunnel in Blender.

Timeline initially seemed more tedious then matinee which is why I went that way, but I’m curious how you did it with mathematical functions.

Made some progress between last night and this morning. I was using a landscape spline before, I now have a blueprint spline and I was able to set it up to have an actor follow the path and rotation of the spline. Added a local offset to the actor to get it to line up with the tracks, and now I have a cube that follows the tracks pretty well. It’s far from finished, but I thought I’d update this in case anyone else runs into this.

Running into an issue with frame rate now. This setup brings me down below 10fps. Going to work on solving that, but if anyone has any suggestions, that would help.

Looking over this, I’m wondering if having two timelines is causing an issue. Could you combine the timelines into a single timeline?

Are you moving the spline during gameplay? If it’s set up inside the Construction Script, that only runs prior to runtime (in the Editor, and when building); so it shouldn’t have any effect on runtime performance. Maybe try digging into the tools for analyzing performance, to see where the game’s being hitched up. Unfortunately I don’t have any experience using those tools; I’ve just seen the menu options for them…

I was able to combine them into 1 timeline and it had little to no effect on performance, still below 10fps.

I think it may have something to do with how the spline was setup, because moving points or adding points in the editor takes a moment to update.

Got it, it was enabling collision that smashed frame rate, probably because the mesh was on per poly while I tested it.