1.) UActorComponent::OnComponentCreated (When an actor is spawned in the editor or during gameplay, this gets called for any native components. For blueprint-created components, this gets called during construction for that component. This is not called for components loaded from a level.)- You could override that function in your subclass and flag the component when it’s called
2.) You could add a Tag to the Actor when it’s spawned and look for the tag with ActorHasTag
I’ve built a small project (attached) with a very small plugin containing a native subclass of AActorComponent to validate your solution.
The component UnrReplicationComponentAbstract overrides UActorComponent::OnComponentCreated and prints a log trace.
I’ve used this component in a BP actor called BP_MovingActor and placed some actors in the map.
I’ve enabled and set up World Partition to enable streaming.
In PIE, when I move far away and then come back close, I see that OnComponentCreated is called, which should not be the case in my understanding. Could you have a look at the project and clarify what is going wrong or what I’m misunderstanding?
I’ve updated the project with a press on the space bat that swan the same actor. It allows to compare the behavior between the spawn and level actor. You can download it here : TestReplication.zip - share.corys.fr
Another option would be to utilize RF_WasLoaded according to this thread, but you’d need to ensure the level is saved after dragging the actor in. The thread also mentions AActor::IsNetStartupActor which uses bNetStartup.
I’d recommend the deferred spawning approach where you add a flag, finishing spawning, and then check that flag.