The C++ constructor definitely seems to run before it’s blueprint counterpart, but when it comes to BeginPlay() the opposite seems to be the case. Did I misunderstand?
Ah, so if I put the log above Super::BeginPlay; the C++ code would execute before the BP? I was under the assumption that the Super Statement needs to be the first line in a virtual method. You can see that it’s happening in the lecture video itself here:
The blue highlighted is the blueprint log, and the green highlight is C++. As you can see, it calls the C++ constructor, the BP constructor, then the BP BeginPlay, then the C++ BeginPlay.
If Super:: BeginPlay is what’s executing the blueprint’s begin play, and you can insert code above or below the Super:BeginPlay then I don’t know how accurate Ben’s statement about execution order is.
I forget what Ben says exactly but how is the order execution incorrect? In order for Super::BeginPlay() to be called it must be from with the C++'s BeginPlay() function.
Sorry, perhaps incorrect is the wrong word. What I mean is that the lecture seems to imply that execution order is C++ > Blueprint, but the logs (as they are written now in the lecture) can confuse a student because they seem to contradict that. Maybe something that could be clarified in a future update. Regardless, thanks for the help, I get it now!
Thank you for asking this question! I had the same thing in my mind. According to the logs it does seam like the BP Begin Play() runs before the C++ BeginPlay() which was confusing for me.
But when the Super::BeginPlay() in the C++ is calling the BP’s BeginPlay() then it becomes obvious that the C++ BeginPlay() runs first, but just in order to execute the BP’s BeginPlay() first? Before executing it’s in C++ BeginPlay() code?
Still somewhat confusing … looking forward to see in the next videos what we actually do with that knowledge
void AExample::BeginPlay()
{
// code here is executed before BP Begin Play
Super::BeginPlay(); //BP BeginPlay happens
// code here is executed after BP Begin Play
}