So it seems in C++, Actor BeginPlay is called before ActorComponent. In blueprints, it is the other way round. Weird, but ok.
Now, why is there a _2 in TestActor component? If I put more TestActor in the scene, it doesn’t happen that. Also if I rename TestActor in the scene, it will show it correctly.
GetOwner in C++ also shows the instance is not TestActorBP, but TestActorBP_2. In fact, if I keep deleting the instance and putting it back, it will become TestActor_3, TestActor_4 but that is only for component GetOwner, not the actual actor. What is happening?
I can’t tell why, but the order is correct - and in fact, the code is commented as such:
/**
* Blueprint implementable event for when the component is beginning play, called before its owning actor's BeginPlay
* or when the component is dynamically created if the Actor has already BegunPlay.
*/
UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "Begin Play"))
void ReceiveBeginPlay();
Not really sure how you’re getting the _n numbers, but for me it gives a direct number right after the name. Probably it’s just the editor trying to avoid two objects with the same name in the scene.
E: I recommend using prefixes (BP_ etc.) for assets, to keep in line with the UE4 style. This guide is about as official an unofficial documentation can get.
All along I would assume Actor BeginPlay is first before actorcomponent… The order is weird becos that C++ behaves differently from blueprint.
Regarding this _n, I tested on two different projects on two different machines. . No, it doesn’t have the same object in the scene. There is only 1. I saw some code that in editor bild, it has some component caching, maybe that causes it. The symtom I see is
If I rename the actor, then it works correct
_n keeps increasing if I add, delete items in the scene (in editor). Even one item can be _12 , for example.