I would use a few different objects for the track. One tiled sprite object for vertical track, another tiled sprite object for horizontal track, then make a few regular sprite objects for turns. Add all of the objects into an object group called for example âtracksâ
Next to make a train object move along the track, i would probably use the tween behavior. You can tween the x position, and tween the y position to move from one end of a track object to the other end. Once tween is âfinishedâ you can do the next tween for the next track. Its probably the easiest to go into the track objects and define custom âpointsâ in the sprite to make it easy to find the position to move to (so, create a âleftsideâ point and a ârightsideâ point, then you can tween position using these points for each track object)
I just tried it and actually its difficult to get the speed consistent using tween.
Instead, I used a single track object, and instead rotated it to make the track turn. Then, I added an event to check for train center point within track object to select the track the train is standing on, and apply a force on train in the direction equal to the angle of the track. This makes the train move in the direction the track is rotated in
Iâm not sure how to get a smooth turn using this method though, but it was a lot easier
I tried the tween as well. I used the distance from the train car to the next corner piece and multipled it by 10. The greater the distance, the longer the duration.
It works for 1 train car but additional cars get out of sync when they turn because the car turning is moving slower than the cars in a straight away.
Tweening would work for the engine but maybe not trailing cars.
The shadow clone extension could be used for the cars maybe. The shadow clone extension would make the cars follow the movements of the train engine automatically according to exactly how it moves, but with a delay
Not entirely wrong but hm.
Is it also possible in the future that the size will retain?
Otherwise it is almost impossible that the path and graphics in the game fit together (hit the road or rail network).
I uploaded a new version that fixes the L and V commands and adds a 2nd behavior that uses acceleration instead of tweens.
The example contains a new scene with a train that follows a closed path.