Hi all,
I’m here to ask you what solution you think would be best for train tracks & pathfinding & train movements on the tracks.
What I’m trying to do:
- Allow user to place their own tracks. No need to have free-form tracks, could be built with a series of pre-built tracks pieces (curves, straight, stations,…)
- Separate tracks in ‘blocks’ using signals
- Have trains pick the best path using pathfinding
- Of course, move the trains when needed along those path/trains in a relatively realistic manner
- Trains should be able to have constant/smooth speed/acceleration and follow the tracks/curves smoothly
- End game should allow tens (hundreds?) of trains moving constantly. So the solution should be light enough to run on non-NASA computers… Target is PC, not phone nore tablets
The different solutions I have thought of:
- Physics. Seems like to worse idea. Tracks & train wheels should have colliders. Seems like the worse even if tweeks could maybe make this possible. Would be the worse for CPU even if working
- Splines. Seems too complicated for my application, I do not need free form train track laying
- Waypoints. Seems like the easiest solutions, each track piece could have pre-placed waypoints, all separated by the same distance. Already did early testing, seems ok for now. Exactly the same spacing between all waypoints allows to have smooth movement and constant speed. Waypoints at intersections could be use for a ‘simple’ path finding algorithm
- NavMesh. This one has been proposed to me by a friend, telling me that in recent version of Unity, one could bake them at runtime. If working, might be the lightest solution. I have doubts about width issues on the tracks. Also have doubts on how to later use signals on my tracks to separate tracks in ‘blocks’
Main dilemma I have for now is weather to continue on a waypoint system, or to switch to NavMeshes & bake them each time a new track has been added/removed (this would happen frequently)
Any thoughts? Thanks for your time