0 votes

how to make a railroad where each part of the railroad will be a path that can be connected to the rest and create a closed path

Godot version 3.2.3.stable.official
in Engine by (159 points)

1 Answer

+1 vote
Best answer

path2d uses a 2d curve for the points. I would create the sprites with the different directions of the rail and I would put each sprite as a child position2d at the ends where I want them to connect. Then I would use the path functions to add points to the curve where the position2d in the sprites are. Another more suitable way (although I never use it) is to use tilemap, each tile can be assigned navigation. The tiles can be created ingame and you only have to worry about checking that the tiles to be joined are the correct ones according to the rail check this video:
https://www.youtube.com/watch?v=0fPOt0Jw52s&ab_channel=GDQuest

by (2,260 points)
selected by

The first option sounds simple, but how can you close the points through the code in the path?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.