I need to initialize an actor when it’s created, when the level is loaded, etc. I need this to happen in Editor mode, or in-game. Trouble is, “imaginary” actors get initialized, even if there isn’t an instance of the actor type in the scene. I don’t want to initialize those. And TActorIterator(GetWorld()) seems to be invalid when PostInitProperties() is called. So I can’t use it to tell if my actor is real or imaginary.
I would just put it in Tick, but Tick doesn’t get called in Editor mode. Likewise for BeginPlay().
So how do I tell if an actor is really there, or if it’s just been created as a placeholder?
what do you mean by “imaginary” actors? if you set default pawn in your project settings, it will be spawned (even if you dont want to). what i do is set the default pawn to none and add a custom event make it execute a respawn event (on gamemode). spawn actor of class i want the player to possess and just possess it with the playercontroller.
this is my workflow on blueprints but my guess is it could be translated to c++ since its pretty basic.
I think the Unreal Engine term is a “template”. It’s imaginary because although the class exists, there are no actors of that class in the scene. Not default pawns. Not spawned. Just a C++ class instance, playing no part in the scene or game.