I’ve been trying to learn c++ programming for ue4, and right now I have a problem with overlap detection.
In the C++ programming tutorial, checking overlaping is done by iterating through all objects that are curerntly being overlaped, but with what I’m trying to do I believe that running a function at the time overlaping started would be more useful.
Right now I’m using the base First Person Shooter C++ template.
I’m trying to make the overlapping exactly as described here.
Instead of creating another object, I’m just calling
GetCapsuleComponent()->OnComponentBeginOverlap.AddDynamic(this, &AVRTestCharacter::OnTriggerEnter);
Here’s the function declaration in the header (I’m using the BlueprintCallable macro so I could check that is being recognized in the blueprint view):
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Collision")
void OnTriggerEnter(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult);
And here is the function implementation:
void AVRTestCharacter::OnTriggerEnter_Implementation(AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherActorIndex, bool bFromSweep, const FHitResult &SweepResult) {
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, "colisao chamada " + OtherActor->GetName());
if ((OtherActor != nullptr) && (OtherActor != this) && OtherComponent != nullptr) {
#if UE_EDITOR
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, "Colidiou com o objeto " + OtherActor->GetName());
#endif
}
}
I’m using the _Implementation in the function implementation because I couldn’t compile otherwise.
I’m pretty sure the overlapping is happening because I tried to check it using the blueprint OnActorOverlapBeging event on the event graph for the same object.
No idea what to do now about this, any help is appreciated.