I want to make a train that can move in a curve. I have downloaded a Train Spline Walker unity package.
That package can generate a spline, and the train's locomotive will move in the spline with a flexible direction and rotation. It'll start by the 1st point of the Bézier spline and stop at the last point. I read the code and I'm pretty sure that those points are called ControlPoint
s.
The problem is that I want the train to also be able to move in a line. Because you know, trains in reality can move in a line and also along curves.
The rails (including 2 types: Rail type A is a straight line and rail type B is a curve) can be auto-generated to fit geometrical rules.
I want to attach the Bézier spline to a rail type B (curve) so that each time the locomotive collides with the collision point (which is an empty object I make) of the type B rails, it will follow a script and move along that Bezier spline.
Through a comment suggestion, i have changed the straight line into curve 0 degree, now im trying to change the locomotive from moving a spline into the next spline.
But it didn't work.
Can anyone suggest how to change the locomotive status from moving in a spline to moving in the next spline when it meets the next rail?
This is the link to the code i downloaded: https://onlinegdb.com/gjpF5Snjq