x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Spawn Actor in streamed-level

I dynamically spawn 3 spheres (actor-blueprints) on "event begin play". However, I want each sphere to be spawned on a different stream-level. Because the real project has not 3 spheres but more like 300.000. So I need stream-levels for performance reasons.

But there is no build-in option in the editor (that I could find) to implement this.

Adding the code to the stream-level's blueprint sadly still spawns them into the persistent level.

I tried Rama's plugin ( https://forums.unrealengine.com/showthread.php?3851-%2839%29-Rama-s-Extra-Blueprint-Nodes-for-You-as-a-Plugin-No-C-Required!&p=232851&viewfull=1#post232851 ) but it doesn't seem to work (for me) in the latest version.

Are there any other options besides C++ (which I have no knowledge of)?

Product Version: Not Selected
Tags:
more ▼

asked Mar 02 '15 at 01:45 PM in Blueprint Scripting

avatar image

Napoleonite
562 82 98 144

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

It took a while to figure out how to spawn into a streamed level when using streaming levels, but after all my experimenting, it was quite easy in the end for what I was trying to achieve, so I hope this might help you out Napoleon.

I decided to switch my project over to using streaming levels, and when I tried to spawn my characters and objects, they all were spawned in the persistent level and were not visible on the streaming levels. After a bit of experimenting, here are the steps that I use to accomplish this:

1) Create a new blueprint actor (I called mine SpawnHelper) and compile it (it really has no code in it at all).

2) Drop the actor SpawnHelper into each level where I will want to spawn objects at runtime, and position them where I want to spawn.

3) Open the streaming level directly in the editor, not the persistent level that contains all your streamed levels. This could get tedious with lots of streaming levels as you will have to do steps 4 and 5 for each streaming level.

4) Select the SpawnHelper Actor in the world Outliner then right click in the Event Graph of the Level Blueprint and you can create a reference to SpawnHelper Actor. It will will show the reference as coming from persistent level, but since you are editing the streaming level directly in the editor this is fine.

5) In the Event Begin Play, use SpawnActorFromClass, and set up the pins on how you want to spawn your actors, but you must drag a pin from the SpawnHelper reference to the Owner pin on the SpawnActorFromClass function call. This will then spawn your actor in the sub level where the SpawnHelper instance is.

You can then verify that this is all working fine by opening up the main level that contains all your streaming levels and playing in the editor. If you go to the world outliner and click the little down arrow to the right of the type column you can select level. Then you can see all your spawned actors and they won't show up as being in the persistent level any more, they will actually show up as being in the right streaming levels.

My project is actually controlling the streaming levels from blueprints using LoadStreamLevel and UnloadStreamLevel, so I'm afraid I haven't tested this with distance based streaming. I'm hoping if my game world ever gets big enough eventually I'll switch the game areas to using distance based streaming, i'm just keeping things smaller for testing and proof of concept.

more ▼

answered Jan 24 '16 at 09:54 PM

avatar image

GRWalton
96 2 6 8

avatar image Vesator Mar 02 '16 at 07:53 PM

I dont get it GR... Could you send me your project?

avatar image apsodi Aug 14 '17 at 11:37 AM

Thank you very much!!! That's a good solution, to set the owner of the object to spawn to an object of the streaming level. It works perfectly

avatar image mattr.taylor May 23 '18 at 12:27 PM

Specifically the information in step 5 fixed my problem. Thanks!

avatar image Tom Looman Jan 13 '19 at 04:10 PM

The "Owner" part is the most important part here. When spawning a new Actor and setting the Owner parameter in the SpawnActor node will ensure they spawn in the same streaming level. I don't really like the rest of the implementation as it's very static and manual work,you can roll your own solution of course.

For C++ I have another solution for after the Actor is spawned and needs to move:

 bool ULZGameplayStatics::MoveActorToLevel(AActor* ActorToMove, ULevel* MoveToLevel)
 {
     if (ensure(ActorToMove))
     {
         return ActorToMove->Rename(nullptr, MoveToLevel);
     }
 
     return false;
 }
(comments are locked)
10|2000 characters needed characters left

I had the same problem, but GRWalton you helped me solving it thank you!

First:
I used "createInstance" to generate random streaming levels the actors only spawned in the persistent level

Then: now I use "LoadLevelInstance" and it works totally fine. I don't even needed the SpawnHelper from GRWaltons post

thanks!

more ▼

answered May 31 '17 at 12:55 PM

avatar image

gruschi
41 2 4 9

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question