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.

Leave a comment

Log in with itch.io to leave a comment.