#Why is my interface function firing before begin play

1 messages ยท Page 1 of 1 (latest)

hardy elbow
#

Small update.

It happens on AActor::BeginPlay

[0038.59][616]LogTemp: Super::BeginPlay()
[0038.59][616]LogTemp: TESTING ACTOR, OVERRIDE MyNativeFunction
[0038.59][616]LogTemp: TESTING ACTOR HAS STARTED PLAYING
[0038.59][616]LogTemp: Calling C++ Function
[0038.59][616]LogTemp: TESTING ACTOR, OVERRIDE CPP MyInterfaceFunction
[0038.59][616]LogTemp: Calling C++/BP Function
[0038.59][616]LogTemp: TESTING ACTOR, OVERRIDE MyNativeFunction
[0038.59][616]LogTemp: Begin play has ended.
wise knot
#

look where ReceiveBeginPlay is called within Super::BeginPlay

#

should make sense then

#

or rather i should just say, ReceiveBeginPlay is called within Super::BeginPlay

hardy elbow
#

But my ide can't find definiton for ReceiveBeginPlay so i don't know is happening inside

#

i saw it is at the end

#

but why would it use interface function anyway

wise knot
#

you're literally calling it?

hardy elbow
#

no

#
void ATestingClass::BeginPlay()
{
    UE_LOGFMT(LogTemp, Log, "Super::BeginPlay()");
    Super::BeginPlay();

    UE_LOGFMT(LogTemp, Log, "TESTING ACTOR HAS STARTED PLAYING");

    UE_LOGFMT(LogTemp, Log, "Calling C++ Function");
    MyInterfaceFunction();

    UE_LOGFMT(LogTemp, Log, "Calling C++/BP Function");
    //MyNativeFunction_Implementation(); // Always run C++
    IMyInterface::Execute_MyNativeFunction(this); // Run Active version
    UE_LOGFMT(LogTemp, Log, "Begin play has ended.");

}

First call is after begin play and logging so ๐Ÿคทโ€โ™‚๏ธ

wise knot
#

in your blueprint...

hardy elbow
#

yes

wise knot
hardy elbow
#

Why is my interface function firing before begin play

hardy elbow
wise knot
#

you run your blueprint graph (ReceiveBeginPlay)

your blueprintgraph runs your function

#

oh, wait maybe i see the confusion

hardy elbow
#

wait, so I counted wrong ?

wise knot
#

are you expecting that "Parent: BeginPlay" to run the C++ BeginPlay?

hardy elbow
#

I think it should execute C++ Begin Play which is paren and then run rest of graph

#

so all messages should align

wise knot
#

no, ReceiveBeginPlay and BeginPlay are totally different functions

#

BeginPlay is not a BlueprintNativeEvent

#

Always found that kind of weird but that's what Epic did

hardy elbow
#

okok, ye I see, added small delay and seems in order ๐Ÿค” . At first I though it is redundant call ;d which could be a problem but its fine

#

so whats Parent: BeginPlay ? ReceiveBeginPlay?

wise knot
#

Yes

#

It would call any parent BP Begin Play

hardy elbow
#

I almost get it ๐Ÿ˜…

#

cause I removed parent beginplay and it still runs my c++ code heh

wise knot
#

right, C++ BeginPlay is not a BlueprintNativeEvent

#

AActor::BeginPlay calls ReceiveBeginPlay

hardy elbow
#

Where should i put code to be able to override body in editor ?

wise knot
#

you cannot override ReceiveBeginPlay (BP Begin Play) in C++

hardy elbow
#

can I define this node in C++ tho? :d

wise knot
#

that's ReceiveBeginPlay

hardy elbow
#

so in some child classes I would not use it

#

ah

#

๐Ÿค” ok

#

I won't overhtink this too much I dont have such problem atm