Better approach when spawning actors if the player changes world position

Good day,

I have this method of spawning actors so that when the camera view reaches that place a floor actor will spawn so the player will have something to step on. It kinda feel like my approach is expensive especially if i need to spawn a larger perimeter. Is there any other way?

My approach:
get actor location -> if that actor has displaced a distance do a loop of line traces that is a bit larger than camera view -> nothing hit in the trace then spawn the actor
I’m using blueprints only since I was just prototyping the project. (Sorry for the bad picture I haven’t taken any “paint” class ;)) Many Thanks!!!

I’ve done this sort of thing with collision. So, when the player steps onto a ‘square’, that square spawns various others around it. The tiles watch the player location and destroy themselves when no longer needed…

Would that be a bit expensive? How did it goes on yours? Are there hitches? Thanks a lot!

Not at all. Nowhere near as expensive as line tracing all the time.

Basically when the player ‘collides’ with a tile, it spawns tiles around itself, if they’re not there already. When the player either leaves the tile or is a certain distance away, the tile can destroy itself, and the others it created etc.

Thanks a lot for the help! Been stumbling on the problem regarding the spawning hitches.

How do you mean? There’s a lag when the spawn happens?

Not exactly on the spawning but rather in the process. The line trace loop and the spawning loop. Moreover, I’m using a low end hardware as I was targeting users with low end hardware.

I’m not using low end, but defintely targeting that. I think the main thing is if you see any hit from doing it. Are you noticing any drop in FPS when you use the technique?

Well it is not great drop but in a gamer’s perspective there is a hitch (tested it in stand alone I’m referring to my method haven’t changed it similar to the one you recommended). Just to give you idea what is happening my hardware is just a ryzen 3400G and the gpu is the integrated vega 11. Again, I’m targeting a low end and always trying to make everything efficient. I tried using “map” to check if there exist something there in the 2d coordinate before spawning. If there is, then don’t spawn. Will prolly use an end overlap as you said when destroying the far away actors. Anyways I will update this thread for other to see and might find this helpful. Again thank you!