Best way to implement railroads?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Skipperro

I would like to know what would be the best, simplest way to make a train follow dynamic tracks.

I’ve got train assets (wagons) and tracks assets prepared to build GridMap (square segments). I would like to build a map using those track parts and run a train on it, that would go where the railroad is laying.

Rail Assets

Could you point me in the right direction?

I think i would use paths.
Start- and endpoint at the edges of your mesh (whee the train goes in/out). Then let the Train follow that path. If it is at the end, find the next tile, and use the next path to follow.

whiteshampoo | 2020-05-08 12:54

OK, sound good. Can you give me some example how to add points from GDScript? I can travel in straight line using add_point() but if I try to make a smooth turn I jump all over the place.

This documentation is unclear for me. What’s “in” and “out” exactly?
Curve3D — Godot Engine (3.1) documentation in English

Skipperro | 2020-05-08 17:19

Why do you want to code this?
Isn’t it much easier to create a node/scene for every possible tile and place the path manually?
(Sorry, i have no clue about your project-structe, node-tree, etc. and i never had a similar problem before :P)

Another possible way would be a math-function, that know where to place your train, depending on its progress through the tile. That might be more accurate, but you have to write a function for every possible way in each tile…

@all: any suggestions? please?

whiteshampoo | 2020-05-08 18:10