Box Collision in Actor

Hey guys I’m using an actor as a Checkpoint for my videogame. Basically I just created an actor and added a box collision (and a static mesh) as a component. I need to set OnComponentEndOverlap (for the box collision of course) how can I make this work? I am a blueprinter and with bp it’s so easy, this may be a silly question!
Thanks a lot :smiley:

(ps. I don’t want to use a trigger volume, I need an actor!)



//Some init function (BeginPlay for example)
{
    YourBoxPtr->OnComponentBeginOverlap.AddUniqueDynamic(this, &AYourClass::OnYourBoxBeginOverlap);
    YourBoxPtr->OnComponentEndOverlap.AddUniqueDynamic(this, &AYourClass::OnYourBoxEndOverlap);
}

// declaration in header
UFUNCTION() void AYourClass::OnYourBoxBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UFUNCTION() void AYourClass::OnYourBoxEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);


I did exactly that (only difference OnComponentEndOverlap.AddDynamic) and still can’t print when my pawn overlap it! This is the function I wrote in the .cpp
I have no idea how to make this work so far!

void ACheckpointActor::OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex)
{

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT(“Overlap End”));
}

You need to check the collision details for the box collision comp and all actors it needs to overlapped and set the “Generate Overlap Events” check box. Also
UFUNCTION in declaration before OnOverlapEnd is must be (u need to check it) otherwise it won’t work.

Thanks dudeeee!!! :smiley: I forgot to add UFUNCTION() my bad
Now it’s working but it prints two lines when should just print one, any reason for this? I tried also to add the event from blueprint and it’s still printing two lines

Mb you forgot to delete this call in blueprint? Also try to use AddUniqueDynamic - this can be the reason too (it depends on what is going on and between what).

Nope nothing in the bp! and plus if I play it in standalone I can’t see the box while in editor yes. Idk maybe I am missing something :smiley: here’s my code btw

.h
UPROPERTY(BlueprintReadWrite, Category = “Components”)
UBoxComponent* TriggerBox;

UFUNCTION()
void OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

.cpp
TriggerBox = CreateDefaultSubobject<UBoxComponent>(TEXT(“TriggerBox”));

TriggerBox->OnComponentEndOverlap.AddUniqueDynamic(this, &ACheckpointActor::OnOverlapEnd);

void ACheckpointActor::OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT(“Overlap End”));
}

Everything looks fine. Need to deal with what happens in the BeginOverlap event. If End event calls twice then you have twiced Begin event.

Actually it prints three lines and the only thing I did was restart both engine and vs :S

SOLVED
Two components in my paw had collision enabled, Thank you dude :smiley: