I know same stuff (in different flavor) exists in Blueprints (famous delay 2.0 some years ago).
But now i have problem with ActorComponents, needing to initialize on class init or begin play.
However problem is that actor is created after components, so component for eg. cannot search actor for anything when is created. Yes i can make delegate in actor that component assigns to, and does init when actor triggers it.
However this whole thing defeats purpose of using components, i want them independent from actor they are placed on.
For eg. i want MeshManager_ActorComponent. that searches owning actor for mesh with tag, and changes its material.
Cannot do it on component begin play, it works after famous 2.0f seconds just fine.
However then what? Do i keep on tick looking for mesh component and changing it again and again every tick?
Yes bool varialbe bActorReady? but such code is triggering me.
Are there any nice solutions to this, that do not require tick, and are executed only once?
I see editor can do it, when i expose tag in editor, it is set up at component begin play.
However tag was just example, there are more things (like finding StaticMesh component and storing reference to it, again cannot do it until actor loads, and i cannot set it from blueprints)
i done this, but it really triggers me:
float CurrentTime = GetWorld()->GetTimeSeconds();
if (CurrentTime >= LastSlowTick + 0.5f)
{
if (!bAllReady)
{
DelayedBeginPlay();
}
LastSlowTick = GetWorld()->GetTimeSeconds();
SlowTick();
}
}
void UPlanetManagerComponent::SlowTick() const
{
UE_LOG(LogTemp, Error, TEXT("slow tick."));
}
void UPlanetManagerComponent::DelayedBeginPlay()
{
bAllReady = true;
UE_LOG(LogTemp, Error, TEXT("DELAYED BEGIN PLAY"));
BodyMesh = FindOwnerMesh();
}