How to move all actors in world around the player / in one direction?

Hello!

I want to make a level where the player is inside a train, which is moving along the traintracks. Now since the track is very long, or possibly endless, I think the best way to do it is by moving the world around the player / the train.

Now my question is, how to do that the most efficient way? I found the “Get all actors of class” and “Get all actors with tag” functions, but it says “This is a slow operation, use with caution, e.g. do not use every frame”.
So how can I then move all the actors every frame, without heavy performance losses? Like store all the actors in an array and use that to specify which actors should be moved?

If that’s the way to do it, what is the limit of an array?

Or is there any other efficient method that does not result in real performance loss?

EDIT: As of the question of Tearl, I use a blueprint system to procedually spawn mesh tiles in front of the train (in a certain distance) and foliage (trees, rocks, etc) on top of them. So perhaps I could just move the map tile actors?

I hope you can help me out with this, thank you so much! :slight_smile:

Cheers

Are you ALWAYS on your train? And is it high speed? We did a VR level simulating a high speed train. I used a few mesh BP’s for terrain. Each piece had the mesh terrain and all the associated extras (trees, rocks, fences, etc) in the BP. Then I moved the BP’s. They added in front and deleted in the rear (think endless runner game). For things that whipped by at high speeds, I used a particle system for bushes and catenary poles. The result was pretty good for a short deadline project.

Thank you for your answer!

I will not always be on the train, but if I step off of the train will not move. In that case the environment (the world) doesn’t need to be moved and is stationary.

The speed is relatively slow I would say, like a comfy old choo choo train.

For the terrain I made a blueprint system which is similiar to yours I think, it spawns map tile actors in front of the train, in a certain distance (in the “fog”). Each of these spawns a static mesh (the terrain tile) and some foliage (trees, rocks, etc.) on top of it.
I also wanted to delete them if they move out of distance from the player (in the rear).

How did you move all the actors, did you give them a tag and called just them? And do you think the foliage I spawned on top will move with them, or do I have to call them as well?

Our project was fixed speed for a high speed rail train. So each BP just has a constant movement input. It never turned…the project was more about the train itself rather than what was outside.
For foliage, we did not use the foliage placement tool.

Oh I neither used the foliage placement tool, I spawn the foliage procedually through my own blueprint system.

So the train was always just going forward in one direction? The way I do it now is that the train (the environment) slows down a bit when there is a turn. I still have to figure out how to make the motion more smooth, but so far it is working. :slight_smile: