A Track to Control a Carriage Following It


#1

This impossible roller coaster https://www.babylonjs-playground.com/#SQFG0Q#6 is built from a new function I have developed that builds a track that also contains data on the orientation of any mesh that follows it. You set this orientation data as you wish over sections of the track. It is also possible for a ‘passenger’ in the carriage to turn (relative to its local y axis) to look around as it travels with the carriage. You can see that the passenger turns to look at its friend in red as it starts its ride. This PG gives an overview of the coaster https://www.babylonjs-playground.com/#SQFG0Q#5 .

The data in the track is also used to build the roller coaster rails and sleepers. Over the next week (or so) I will write how to build with the track and details of the function’s coding and PR these into the snippets section of the docs.

At some stage I might even write an editor to make building a track easier. Happy playing :smiley:

EDIT: I really should mention that I was inspired, as I often am, by one of @Wingnut’s ‘can we code Babylon.js to do this’ suggestions. Often like to give them a go.


#2

What causes the flickering to occur when going around curves? At some point I am going to have to make a moving camera that follows a path, and am looking to avoid any issues that might occur.


#3

Good question to which I do not know the answer. I was just pleased to get the camera to do what I wanted. Smoothing it out would be good.


#4

This looks great and fun to play with! It reminds me of @jerome’s roller coaster:
http://jerome.bousquie.fr/BJS/demos/rollercoaster.html


#5

excellent !!
To avoid the flickering, you could force the camera view matrix recomputation before each frame (I can’t remember the method … scene.getViewMatrix() or something like this)


#6

Those curves are fantastic!!! :grin:

For “A Track to Control a Carriage Following It”… it is a tough challenge (to me).

Would a bone make a good train-car-coupler?

OR MAYBE just run a clone n sections back…?

Through the same exact normal math.

Thanks JohnK

:sunglasses:


#7

That’s one way - https://www.babylonjs-playground.com/#SQFG0Q#7


#8

WOW!

FANTASTIC ROLLER COASTER!

(link above) by JohnK

Rollercoaster editor across (infinite) random-block-city :+1: