How to create a train timetable

I’m trying to build a sort of modular train timetabling system for a game, it’s in concept at the moment but I’m just thinking about what would be the best way of going about it.

The idea would to have each timetable as a custom blueprint if possible, such as having my own instruction nodes. Such as “go to location” and then being able to select a certain location on the properties tab for that variable, and “formation” having an array of data to use.

Would this be possible to do entirely through blueprint or would C++ be needed to create the custom framework?

Are the timetables like nodes / stations the trains travel between? Once a train arrives at one, it can fetch data from the timetable telling it where and when to go?

Kaelyn, for realism you should have an additive random float or integer to the timetable, because we all know that no train is ever on time. :thinking:

2 Likes

The timetables would essentially be a set of instructions - such as start at this time in game, go to this point, go via this point (without stopping). They could be specific stations or signals (such as stop at signal and reverse, for swapping tracks).

Others could be added later but these would be the minimum required to get something together.

Very true :wink:

And how do they work? Are we controlling the timetables at runtime or you need to edit the data outside of PIE? Both?

Lets say I have a cube train and a timetable actor with some variables:

The train arrives at the station, waits and then choo-choos away to a new destination? How close are we to what is needed? Obviously, the end product would be a tad more complex and ever so slightly grander in scope.

As you can imagine, I’ve used a train once, but struggling to conceptualise what is really needed here… :innocent:

The idea would be to store them in their own sort of definition file in the project, and then accessed in runtime; the player would then control said trains against that timetable and the game would then compare the timetable vs the player’s actions and store that to their account.

So tl;dr the timetable itself wouldn’t be writable outside of the editor but it would need to be loaded along with the level map to be used.

However one thing it would need, is to load the timetable from any given time as the player can set the start time of the simulation to any time, so the system would need to be able to take the time selected and then be able to spawn the correct trains rather than from the start of the timetable.

It would also need to be modular, as each “simulation”, each level basically, would have its own timetable based on what’s within the simulation chosen (the stations, trains, etc) and the different train types (length, type of train, power type, etc)which is why I was thinking potentially looking into a custom blueprint function library, which is why I’m currently learning how UE C++ works to see if that could work.

The game itself is a mainly UI focused train signalling game, so the timetable would include:

  • Stations the train is stopping at
  • Scheduled arrival and departure times
  • Route information (which line its scheduled to use, fast, slow, suburban, any line can have a different name depending on where it is irl, as well as clear notifiers of “this train must change track at this signal” rather than only allowing stops/changes at stations)
  • Service descriptors (unique IDs for that specific train)
  • Entry and exit points (where does the train spawn and despawn
  • Couple / Decouple locations (does it join another service or detach into two separate?)

Something that could also be included in the timetable file is a boolean that determines whether the train must enter on time or could be randomly delayed.

Would this be possible to do entirely through blueprint or would C++ be needed to create the custom framework?

Nothing in here screams C++ to me. Not unless you must run hundreds of trains and need to optimise heavily. I’d keep it BP only, come up with a prototype. You then move unwieldy code to C++; if at all necessary. But yes, you’d need to create an entire system from scratch, sure.

  • data can be handled by data tables, easily accessible and easily editable
  • stations serve as timetable hubs orchestrating and issuing orders, telling the trains where and when to go, how to organise the carriages and so on
  • each timetable station can be fed additional data through user interface

Providing I understood the game loop correctly (UI focused train signalling), I can see it work this way. Seems like it’s worth exploring.

The idea would be to make the game completely UI only, which could be a nightmare through UMG but it could work.

Depending on reception and how the game goes, I would then look at moving things to also show physical trains following the same instructions, which could the exact same framework with some modifications. However I feel like UI only could work well for a game like this.

Game loop would be:

  • User starts game
  • User picks to either start a new simulation in either single player or multiplayer along with start time and any pre-determined scenarios (track closed, route diversion etc)
  • Load simulation with the relevant timetable from the start time
  • if multiplayer, allow people to join and replicate that to all players
  • Trains spawn with relevant timetable, length and all the required info from timetable
  • All actions player does is logged and shown on a performance analysis page for user
  • At end of session, player is given final score, added to overall XP and reputation. XP is used to unlock more difficult simulations and reputation is a way of filtering multiplayer sessions to only those with higher reputation.

That’s the core premise at the moment.

My only advice at this point is to not go this way. You will run into so many issues that it will consume you. Making 2d games in UE is already difficult enough. Exclusively relaying on UI for gamplay? Sure, it’s doable but I wouldn’t personally dare.

Why not have a top-down ortho cam view on a very simple gameboard. Treat it like a board game. You could even use sprites. It will look very much 2D but you have all the benefits of actually using the game engine.

The aim would to have something similar to the real life system, which is all computer based.

Something hybrid could work, say a 3D space in a signalling control box but then by clicking on a computer to use the signalling desk? Either exclusive UI where it takes up the whole screen, or by plastering the UI on the computer screen?

So the game would focus on this massive screen in the back, right?

s__3614678_555control_room_05

This would be the centrepiece where all the action is being tracked?

Essentially.

Each player in multiplayer would control a different panel, sortof a boundary area within the main simulation. The screen at the back would be available for every player to see, but would only be able to control the area within their own boundary.

In singleplayer, you’d have control of the entire simulation, but I plan to add an AI mode where you choose which panels you want to control, and the AI would control the others.

I believe it would quickly become a logistical nightmare when attempted in pure UMG. Probably doable but with so many caveats. Just knowing that you will need to pan around and zoom onto a large canvas hosting innumerable widgets while drawing lines whose ends go off-screen makes me shiver.

But again, perhaps this is less dynamic than I think and the “game maps” - the layout - can be pre-made as a huge image. But even then, translating all the coords… at different DPIs.

Quite chuffed I don’t need to do it this way. ;p


Were I tasked with something like this (and had enough creative freedom), I’d opt for an ortho camera view and disguise the whole thing as a monitor display.

You can still project UI elements on top - override screen-space widget components for that crisp look, they require no tracking, work off-screen, can already run logic. You could use splines which makes design a breeze.

Heck, you could even pull it through a render target and project onto something else. As in, have a picture-in-picture mode.


Disclaimer: never made anything similar. In hindsight, I may not be the best person to answer. I thought it was just about trains, so I got excited.

artworks-000013897241-3udk3h-t500x500

1 Like

Ortho camera could work, I’ll need to have a look at how to do such a thing but it’s worth exploring.

Thanks for the advice :slight_smile:

Nothing in here screams C++ to me.

I absolutely agree!