Hey,
I have some trouble understanding why Begin Overlap is not working when I want to change the Function name.
This is my Code:
headerfile:
UFUNCTION(BlueprintCallable)
void BeginOverlap(UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult &SweepResult);
UFUNCTION(BlueprintCallable)
void EndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
.cpp Constructor:
PressurePlate->OnComponentBeginOverlap.AddDynamic(this, &APressurePlateBP::BeginOverlap);
PressurePlate->OnComponentEndOverlap.AddDynamic(this, &APressurePlateBP::EndOverlap);
Functions:
void APressurePlateBP::BeginOverlap(UPrimitiveComponent * OverlappedComponent, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
AUsableObject* RequiredActor;
RequiredActor = Cast<AUsableObject>(OtherActor);
UE_LOG(LogTemp, Warning, TEXT("Before Required Actor Check"))
if (RequiredActor)
{
//...
}
else {
UE_LOG(LogTemp, Warning, TEXT("Required Actor cast failed"))
}
}
void APressurePlateBP::EndOverlap(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex)
{
AUsableObject* RequiredActor;
RequiredActor = Cast<AUsableObject>(OtherActor);
UE_LOG(LogTemp, Warning, TEXT("Before Required Actor Check"))
if (RequiredActor)
{
//...
}
else {
UE_LOG(LogTemp, Warning, TEXT("Required Actor cast failed"))
}
}
This Code is working fine.
But I wanted to add another OnComponentBeginOverlap, so I renamed the functions into :
void PPBeginOverlap(UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult &SweepResult);
UFUNCTION(BlueprintCallable)
void PPEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
In the Header and everywhere in .cpp it needs to be changed… But When I do this, the Box is not triggering anymore.
Is “BeginOverlap” an existing Function within the engine? Or why is this not working?
EDIT: So after many tries I figured out, my problem gets solved when I call “OnComponentBeginOverlap” in BeginPlay, instead of the constructor. But this is really weird… I still do not understand why it do not work anymore, when I rename the function in the constructor? First I thought it could be, that it is saved somewhere in the memory but I restarted my PC a few times. I closed UE4 and “Generated visual Studio files” there is no difference.
Every time when I renamed my function “BeginOverlap” it works again.