Get object by class on begin play doesn't get objects located on sublevels not streamed yet despite being on persistent level

luke bennetto
Sun, 26 Sep 2021 05:33:42 +0000
World Creation

Hey guys.

I am making a game similar to the forest, where tree cutting and crafting etc are a major focus. I currently have it all working except for a problem I am having with my Level Streaming and collection of my foliage instances on eventBeginPlay.

Currently on eventBeginPlay I have a function to collect all the tree objects that are spawned by my procedural foliage volume and add them as instances in world space, these are then spawned as my tree static meshes. Then when the player gets close enough to a tree to chop it down, that tree static mesh gets swapped out for my tree actor that I can interact with. It is then swapped back out to a static mesh when I move away from it.

The problem I am having is that not all the objects that I collect on beginplay event are being collected, specifically the ones on different sublevels that aren’t streamed in yet. They stream in as I move closer to them but they obviously miss the collection that happens at begin play so they are not gathered up with the rest of my trees for interaction with later. I have a large map made up of a tile set of 5X5. Each tile has 2 LODs, one streaming in at 50000 and the other at 2 000 000. This is so I can see the mountains in the far distance. I have tried adding my procedural foliage volume to my persistent level thinking that would have them permanently spawned in at begin play but that hasn’t worked and they all still spawn in as the sublevel they are physically located on load, despite them being on the persistent level. I also tried adding them to another sub level that had a streaming distance of 2 000 000 but that hasn’t worked either.

I am just wondering if there is a way to force these objects to be spawned on begin play regardless of which sublevel they are physically located on so they can all get collected together. or if there is an easy way of re-triggering the collect tree function when these sublevels are streamed in.

Hopefully that all makes sense and someone can head me in the right direction.

Thanks in advance
Luke

3 posts - 1 participant