Train tunnel infinite loop

I’m looking to make a train going through a tunnel, i would like the tunnel to keep looping to make it look like the train is moving. The players will be in side the train. I am currently using a Cframe loop to move the walls and train track backwards and forwards. But this isn’t very efficient so if you have a recommendation on what i could do please leave it below. Thank you.

Code i am currently using to do the moving loop:

4 Likes

You can try using CFrame:Lerp() in a loop to change the position of the primary part of the train. And once it the train reaches its goal, you set it back to its original position.

2 Likes

Do you want your train to go backwards? If not you could cycle through two wall parts moving them back to the start when the second part goes by. I’m not sure of the most efficient way to animate the part though.

2 Likes

Ok thanks ill try using that, do u reckon it would be best to move the walls or the train?

2 Likes

In your case, the train. Moving the walls would cause lag for most people.

2 Likes

Thank you, ill try your solution too and see how i can try to animate the parts

1 Like

I’m not sure about this. Imagine if he has an elaborate train interior, if he leaves it fixed anchored, it will simplify his building(no welding) and allow more detail without lag of moving all of the welded pieces.

I guess it depends on his train and game idea.

I would be very interested to see the effect of a moving wall, perhaps just a simple brick with maybe a blurred texture(to add some faked motion blur) I think that along with some camera shake could be very convincing.

This is assuming you want your train to keep going infinitely.

1 Like

I’ve looked in to using a beam on a part, this could be an option too.

1 Like

Good idea, the wall would be the beam texture, you make it big enough to cover the windows. I’d like to see what you come up with here, sounds interesting.

2 Likes

I couldn’t wait to see what it looked like, it works pretty awesome, I threw together a quick Place:
https://www.roblox.com/games/6505746647/Beam-Train-Demo

Its so convincing that this effect was making me nauseous when I was making it, haha.

I don’t have mobile, can somebody see if it lags on mobile?

5 Likes

Yeah same when i tested it, it was hard to look at too.

I disabled the beams and put a one line script in them to enable at run time.