Body Position Help

I would like to make a stable train physics system using body position. In other posts I’ve seen that people say to use other methods but after looking at it more SCR uses body position and body gyro which makes derailment impossible and the trains run along the tracks smoothly without any issues.

Now I know you can use track nodes etc, but in my rail simulator the path the train could take will not always be the same, this can differ from route, to operator or if a junction needs to direct me to a free platform incase the other one is occupied.

When I also had a closer look at SCR’s the BodyPosition.Position will always change depending on where you are moving to, even down into decimal figures. This also goes for the body gyro.

I couldn’t find any track nodes or sensors that guides the train and if there were sensors there would of have to of been like 10 every stud.

Now I could just make a script that just adds a Vector3 of (1,0,0) which would indeed make the train go in one direction but then what do I do about turns or slopes? Well it would obviously involve body gyro but I would still need a way to detect if the train is turning or going up / down a slope.

Now one theory I have is that the train has one centered engine part in the middle of the coach and then a part infront rotates or changes depending on what way the track is going and then the engine’s body position and adjusts to it.

I also plan for these trains to be manually controlled with throttle and allow it to be instantly stopped if an emergency brake is applied.

Thanks for reading this and I hope someone could help me with this.


Basically you change the trains body position every time it reaches a point (via magnitude)

1 Like

How would that work though? Magnitude is the distance inbetween two parts.

1 Like

This probably is wrong but you can use pathfinder to reach a point but I don’t think it would be manually controlled.

It could work because if the train is 10 studs near the train station it can change BodyPosition or stop the train.

when I meant manual controll I ment speed only. So that should be fine.

Could also work as well, the tutorial roblox provides: Character Pathfinding | Documentation - Roblox Creator Hub uses a humanoid and MoveTo() but for this to work on a body position i cant just do the part.position because then the train would jump from point to point which would look horrible.

Although a way around this could be moving the train every 0.01 studs until the magnitude inbetween the trains trackers part and the waypoint (on a z/x axis ignoring Y) has been reached

I would also have to figure out how to corrospond the crame of body gyro (for rotation) aswell which could maybe be done with magnitude im not entirely sure.

I’m not experienced in this area of scripting although I wish to learn it and figure it out with others aswell.

Also I would also have to do some weird crap to that aswell since the path could be blocked if a junction is in the way that hasnt opened up yet simply because the train hasnt even approached the sesnsor setting it off. I will experiment with this and see what results i get

Yeah it completely ignored the track image

even removing the other train parts which wouldnt be doable in game anyways gives the same result

EDIT: Even adjusting the paramaters still gives the same result