Hi guys, I just started using UE4 a week or two ago and am trying to get a very basic project going to familiarize myself with the engine, tools and C++ API… I’ve defined a basic class that inherits from Actor and wanted to describe some default behaviour for a few events. I then wanted to be able to override this in Blueprint using custom events. My issue seems to be that the default behaviour I define in my C++ class doesn’t seem to work so I’m wondering what I could be doing wrong…
My header file contains
// On Overlap implementation
UFUNCTION(BlueprintNativeEvent)
void MyOnBeginOverlap(AActor* MyOverlappedActor, AActor* OtherActor);
void MyOnBeginOverlap_Implementation(AActor* MyOverlappedActor, AActor* OtherActor);
// On End Overlap implementation
UFUNCTION(BlueprintNativeEvent)
void MyOnEndOverlap(AActor* MyOverlappedActor, AActor* OtherActor);
void MyOnEndOverlap_Implementation(AActor* MyOverlappedActor, AActor* OtherActor);
In my C++ class I define my two functions
void AHybridSphere::MyOnBeginOverlap_Implementation(AActor* MyOverlappedActor, AActor* OtherActor)
{
FString outputString;
outputString = "Hello From C++!";
Text->SetText(FText::FromString(outputString));
}
void AHybridSphere::MyOnEndOverlap_Implementation(AActor* MyOverlappedActor, AActor* OtherActor)
{
Text->SetText(NSLOCTEXT("AnyNS", "Any", "Goodbye From C++"));
}
And in my class constructor I’ve included
OnActorBeginOverlap.AddDynamic(this, &AHybridSphere::MyOnBeginOverlap);
OnActorEndOverlap.AddDynamic(this, &AHybridSphere::MyOnEndOverlap);
When I move my player to overlap with my actor the text component does not change it’s text so I’m wondering what I’m doing wrong…
Cheers!