Hi there,
I have a component class that I am trying to find and access from any overlapping actor - how do I go about this?
OtherComp and OverlappedComp only return comps with colliders.
These are some methods I have tried, but to no avail.
void AFPSStorm::OnBeginComponentOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
UE_LOG(LogTemp, Log, TEXT("WE OVERLAPPED WITH SOMETHING %s"), *OtherActor->GetFName().ToString());
//UFPSStormComponent* StormComp = Cast<UFPSStormComponent>(OtherComp);
TSubclassOf<UFPSStormComponent> StormCompClass;
UFPSStormComponent* StormComp = Cast<UFPSStormComponent>(OtherActor->GetComponentByClass(StormCompClass));
if (StormComp != nullptr)
{
UE_LOG(LogTemp, Log, TEXT("STORM FOUND A STORM COMP"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("NO STORM COMP WAS FOUND"));
}
}
This is how UFPSStormComponent is set up in the header
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "StormComp")
UFPSStormComponent* StormComp;
And in the constructor
StormComp = CreateDefaultSubobject<UFPSStormComponent>(TEXT("StormComp"));
StormComp->StormEvent.AddDynamic(this, &AFPSCharacter::CharacterStormFunction);
Any pointers on how to access with comp from an overlapped actor would be great =)
Thanks in advance!