Hi everyone! I recently became interested in how the train in the game Dead Rails is built! Initially, I did not have a specific idea of how it was done until I came across this topic. To my surprise, the creator of the original game, @RiccoMiller , himself responded to this and was marked as a solution.
As a true fan of the game , I decided to experiment with this… And so I would like to present my template that I managed to create!
You can download this place here:
Dead Rails Train System.rbxl (158,0 КБ)
First, watch the demo.
As you can see, the player is riding a railway on a cart that curves to one side. He can also change its speed.
How it works
First, let’s figure out what sets the cart in motion.
As the creator of the original game himself said, he uses a special Mechanical constraint, which has the Prismatic class. This constraint is located inside the cart and its ActuatorType
is Motor
. This allows the cart to maintain speed and change it due to the ThrottleFloat
property of the VehicleSeat
. The start of the movement where Attachment0
is located is an invisible BasePart
that moves forward every time a rail is passed.
The wheels of the cart are rotated by the HingeConstraint
ActuatorType
which is also on the Motor
. AngularVelocity
(speed) depends on the current AssemblyLinearVelocity
of VehicleSeat
.
Okay! Now let me explain how the automatic generation of rails and sand happens.
A rail is a model
consisting of its visual part, as well as an invisible hitbox at the bottom and an invisible BasePart
, which is its end (PrimaryPart
). Every frame, a ray comes out from the base of the cart, shooting downwards and hitting the hitbox. If this happens, the game checks whether this rail is the last one, if so, it creates new rails at an angle of 0.25° from the end of the last one. Perhaps this system could have been made simpler and more reliable, for example by checking the nearest rail or something like that…
Sand is generated based on cart current position in the world and the border of the last sand base. If the distance becomes small, a new sand base appears.
That’s all! I hope I helped you figure out the basics of this game…
TOP SECRET!
I created this skull 2 years ago, and now it is used in Dead Rails…
https://create.roblox.com/store/asset/15090308072