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"

Delay before adding widgets after level change


I have a main menu widget, that must be activated after a map change to the 'Menu map' like so: alt text

The 'State Transition' Macro essentially collapses all unused widgets. After this Macro, it will then check for all required main menu widgets, if they are invalid, create a new one and add to the view port.

I am baffled about two things,

  1. Why is it that when I remove this .05 delay, it does not display any widgets? (It took me hours to figure out that it only works when there's a delay)

  2. Why is it that every time the map is loaded, the widgets are considered invalid and must be created again? Is this due to when the level changes, all widgets are destroyed?

Product Version: Not Selected
capture image.png (267.1 kB)
more ▼

asked Aug 10 '16 at 08:25 PM in Blueprint Scripting

avatar image

102 19 20 24

avatar image Spiris Aug 11 '16 at 04:34 AM

You have in fact answered your own question. Loading a new map in the standard sense destroys every single thing with the exception of the GameInstance and other UObjects that do not rely on the Level as their 'World'. So basically any time you want to change maps, be ready to remake everything you want available to you when that map has loaded itself into memory. Without a map, no Actor or Actor child (widgets) can exist.

avatar image TornadoStorm Aug 11 '16 at 05:49 AM

So that means I have to always have a delay somewhere when changing a map to be safe? Or is there a special way to detect if the map has loaded or whatnot?

avatar image Spiris Aug 11 '16 at 06:28 AM

There are quite a few different ways to detect if a level is loaded in C++, but one simple yet effective way in blueprints is to use your Level Blueprint's Begin Play event. Assuming you have other state based activities you would like to do in GameInstance and you are storing state variables there, there is value to both methods shown: alt text

avatar image TornadoStorm Aug 11 '16 at 06:55 AM

Ah alright, I'll see what I can figure out. Thanks!

avatar image MADHOUSE Sep 24 '17 at 05:06 AM

Hmm is this a changed behaviour? I seem to recall having to clear widgets very often since they would persist over level loads, which most of times was very annoying. I recently started rewamping core game instance functions and noticed that I now had to solve the main menu being drawn before the level had loaded, even tho the load level call comes before the hud instructions, which instead caused these issues the op was having.

Spiris answer is correct and pretty much how I solved it as well, relying on a delay can be flimsy when using it to offset execution of something critical, so I wouldn't really recommend that.

avatar image TornadoStorm Sep 24 '17 at 02:00 PM

No changes that I have heard of so far. Still is the same where it takes some time before widgets can be created in a level.

Yes it's a much better method to use BeginPlay instead of a delay, because who knows, maybe slower machines require a longer delay.

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

0 answers: sort voted first
Be the first one to answer this question
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