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"

Unload Level does not trigger Latent Actiont

I'm working on some checkpoint mechanism, that will reload some parts of the level when needed. I wanted to have all of the sublevels loaded on from the very begging, so I set all the levels to be always loaded. When I need to reload one of the sublevels, I use UGameplayStatics::UnloadStreamLevel, and I put some function that triggers UGameplayStatics::LoadStreamLevel as a latent function argument, so It should be loaded up again, right after it gets unloaded. The problem is, that after level gets unloaded ( which works fine ), the latent function doesn't get triggered. It does only if I set level to be Blueprint Loaded. But the problem with that solution is that I need to load sublevels manually, so I need to add additional loading screen after the actuall loading screen that is being shown when automatic level loading is done. Manual level loading seems to take more time too. Is there any way to fix that? How can I reload automaticly loaded level ? Thanks in advance!

Product Version: UE 4.16
Tags:
more ▼

asked Oct 24 '17 at 09:00 AM in C++ Programming

avatar image

Krzysiek_TATE
219 4 13 18

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Here is an example that seems to work for me:

 FLatentActionInfo LatentInfo;
 LatentInfo.CallbackTarget = this; // The class that the Execution function is in
 LatentInfo.ExecutionFunction = "SomeFunctionInTheCallbackTargetClass";
 LatentInfo.Linkage = 0;
 LatentInfo.UUID = 0;

So if I have a function "void MyClass::LoadingFinished()" which I want to call at the end of a load:

 void MyClass::UnloadLevel()
 {
     FLatentActionInfo LatentInfo;
     LatentInfo.CallbackTarget = this;
     LatentInfo.ExecutionFunction = "LoadingFinished";
     LatentInfo.Linkage = 0;
     LatentInfo.UUID = 0;
 
     UGameplayStatics::UnloadStreamLevel(this, *LevelNameHere, LatentInfo);
 }
 
 void MyClass::LoadingFinished()
 {
 
 }

more ▼

answered Oct 24 '17 at 02:18 PM

avatar image

Dune
1.9k 53 40 200

avatar image Krzysiek_TATE Oct 26 '17 at 12:11 PM

Hey @Dune. This is exactly what I do. But it doesn't work. "The problem is, that after level gets unloaded ( which works fine ), the latent function doesn't get triggered. It does only if I set level to be Blueprint Loaded" - as I wrote before.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
     FLatentActionInfo lai;
     lai.CallbackTarget = this;
     lai.ExecutionFunction = "LevelLoaded";
     lai.Linkage = 1;
     lai.UUID = 1;
     UGameplayStatics::LoadStreamLevel(this, levelName, true, false, lai);
 
 

... works here. some forum posts have said Linkage and/or UUID need to be set to >0. didn't try without.

more ▼

answered May 15 '19 at 01:57 PM

avatar image

eblade
6 1 4

avatar image Krzysiek_TATE May 16 '19 at 07:19 AM

The bug was there back then, and I'm pretty sure I saw it fixed in the meantime.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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