What is the best practice for referencing a component to another actor?
I am storing references to components that belong to other actors within certain actors. I am wondering what the suggested way to implement this, in terms of both member declaration and definition.
For example in my custom actor class, I can declare this reference in different ways:
USomeComponent* otherActorsComponent;
or
UPROPERTY(Transient)
USomeComponent* otherActorsComponent;
And I can assign an initial value to this pointer like:
void BeginPlay() {
// .....
otherActorsComponent = otherActor->FindComponentByClass<USomeComponent>();
}
I ask because I’m having frequent issues of what appears to be the garbage collector causing sporadic crashes on Start, during, and at Stop of PIE. I’m not having issues that directly implicate any of these references, but I’m wondering if I’m messing up my GC object hierarchy somehow.