Working junctions
I now have trains moving from spline to spline crossing in-between junctions.
It turned out to be quite straight forward: Because the carriages receive u values relative to the head of train, those values just become negative when the head of the train crosses a junction onto the next spline. So we can just loop through previous traveled splines until an appropriate place to put that carriage's u value is found, and then use that spline to get the right position and angle. This means that the train keeps track of the last 2-3 splines it has traveled through and discards them once they aren't referenced any more (the amount of splines and frequency of discards depends on how dense the junctions are, and how many carriages long the train is - since a large number of carriages - like those in the video - will span across multiple previous junctions and splines).
Still not perfect - there are probably easier more efficient ways to do this - but it's a big milestone, as it's the beginning of being able to meaningfully control where the train goes.
(Although right now it just chooses the first junction direction to take and takes it - I need to make this player controlled).
It also means that for the first time, trains can run complete circuits on loop properly, which hadn't been possible before.
Train game
A work-in-progress game probably featuring trains. Not a puzzle game.
Status | In development |
Author | d w roberts |
Tags | Life Simulation, Trains |
More posts
- Train delayed (or cancelled)Nov 04, 2023
- Back on track(s)Jun 01, 2023
- Train yardsApr 23, 2023
- Frame timing hellApr 21, 2023
- Basic object placementApr 15, 2023
- Spline cleanupApr 10, 2023
- NPCs, shops, inventoriesApr 09, 2023
- Basic gameplay milestoneApr 03, 2023
- Invisible technical workApr 02, 2023
- Putting some more thought into artworkMar 26, 2023
Leave a comment
Log in with itch.io to leave a comment.