Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Thanks! I'm super happy to hear that you like derail mechanics as I put a lot of effort into it.

Maybe it should be separate devlog, but in short it's not that complicated:

1. every frame curve of a track for each train car is calculated using math and angles. Having car position and two points from a track in front of the car I can calculate angle of a curve.

2. Next, Angle is multiplied by speed (with some additional fine-tuning).

3. If 'risky' threshold is met, sparks start shooting and I keep track how much above threshold car is.

4. If second threshold is met, then car is derailed.

There is a little more nuance to it (car number from locomotive matters etc), but not much. The hardest part was to find right formula to multiply angle by speed, and then to balance thresholds so it's not too easy, but also not too unforgiving for the player. I think it can still use some tweaking, but it's not a priority for me now to tune it more.

Thanks a lot for the in-depth explanation. It was really inspiring to read. I can also see why you chose to sample two points ahead instead of one ahead and one behind. That forward-looking approach subtly encourages players to anticipate what is coming, which feels very nice in gameplay.