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"

Event Begin Play Order

Hi @all,

First of all: I'm pretty inexperienced with UE4.

I discovered, that the "Event Begin Play" from my Actors are fired before my Game Mode, Player State or Level Blueprint is fired.

In this Order the "Event Begin Play" is fired:

  1. Actors

  2. Game Mode

  3. Level Blueprint

  4. Player State

My Questions:
Why does the Actors Begin Play load, before the other "Event(s) Begin Play" are loaded?
Where should I initialize my Actors, if I use Method from for example Level Blueprint?
Should I put the reference to the Level Blueprint to execute the Method for specific Actors on "Event Begin Play" ?

Thanks in advance for any answer.

Yours Michael

Product Version: UE 4.21
Tags:
more ▼

asked Jan 07 '19 at 09:15 PM in Blueprint Scripting

avatar image

Halki
7 1 3 6

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

4 answers: sort voted first

I have had this issue myself with creating widgets and referencing the data in them causing errors because of the order things are initialized. My work around as it seems certain BPs are always slower than others is that if you need something to happen first put a small delay after begin play or whatever custom event that you don't want to run until the first thing happens first. This has worked well for me in the past.

more ▼

answered Jan 08 '19 at 06:48 PM

avatar image

Nebula Games Inc
4k 22 9 14

avatar image Halki Jan 08 '19 at 07:27 PM

I heard some months ago "If you think that you need to Delay something to solve a simple Problem, just think again".
And I'm pretty sure, that this is a very common thing, that shouldn't solved with Delay at all.

I "solved" the Problem with register my Actors (10 Actors) to the GameMode and do Stuff within Level Blueprint with the Array of Actors I got stored in GameMode. This is my "workaround".

If anyone knows a better (common and/or performant) way to solve this common issue, feel free to post it here.

avatar image Nebula Games Inc Jan 08 '19 at 07:35 PM

Whatever works for ya ha There are many ways to skin a cat, in my case delays were a simple fix. It is basically the same thing as creating a custom event and having it called in the order you like from the BPs you want. I spare myself the extra custom events simply by delaying the begin play event in certain BPs.

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

The event begins play event is triggered for all Actors when the game is started, any Actors spawned after the game is started will have this called immediately. All of the events are called pretty much simultaneously but the exact order is discussed here: https://answers.unrealengine.com/questions/225833/any-predetermined-execution-order-for-the-begin-pl.html you shouldn't have to worry about them being called in an order as they are all called almost exactly at once.

more ▼

answered Jan 07 '19 at 10:29 PM

avatar image

crazyhooligan77
33 2 2

avatar image Halki Jan 08 '19 at 06:55 AM

My Calculation Logic within Player State, which is needed within Actors and other Classes, is initialized to late. So the Order matters to me. And the Order when which Event begin Play is fired should be known, because of initializing Stuff in general.

avatar image Halki Jan 08 '19 at 07:04 AM

Your link just refers to a post from a user, which has written that he is not sure either and want to get the opinion of a pro. In addition, the Event Begin Play Order of the other commentaries are not equal. Maybe the Event Begin Play did execute "randomly" or all mentioned Execution Orders within the post are wrong (cause they don't match at all)

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

BeginPlay is called for each object when it's ready. It is generally not wise to assume any other objects state at that point, even if you find it by debugging, because it may change. It is however, somewhat logical to assume that a Level is only ready after all of its preset actors are initialized.

more ▼

answered Jan 08 '19 at 08:02 AM

avatar image

const_iterator
1 1 3

avatar image Halki Jan 08 '19 at 10:49 AM

Thx for your answer. Could You also answer my other 2 Questions?

avatar image const_iterator Jan 09 '19 at 11:40 PM

Your other questions are not so clear. It really depends on what you're trying to achieve. If all your actors need information about the level and they all are pre-set then you can probably initialize them in the level blueprint, but if they are also dynamically spawned, then you'd want to initialize them after they have been spawned. It is not uncommon to divide the initialization process so different parts of it happen at different timings. I could perhaps help you more if you be more specific about what you are trying to do.

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

OK, I understand your question a little better now. If you want to make sure that one thing happens after another one has been called try setting one to start after 'event begin play' and then the other one starts after a custom event then call the custom event in the first one. alt text

alt text

hope this helps :)

sniiip.png (54.4 kB)
sniiip.png (33.6 kB)
more ▼

answered Jan 08 '19 at 04:36 PM

avatar image

crazyhooligan77
33 2 2

avatar image Halki Jan 08 '19 at 06:41 PM

Hit compile, and you will see that an error will be thrown.

(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