Download

Pawn being hit or overlap with another actor

Hey GUys,

I’m trying to get event for hit or collide/overlap with another actor but without success.

my code is here:


GetCapsuleComponent()->OnComponentBeginOverlap.AddDynamic(this, &MyChar::onSomethingOverlap);
GetCapsuleComponent()->OnComponentHit.AddDynamic(this, &MyChar::OnHit);

void MyChar::OnHit(UPrimitiveComponent * selfComponent, AActor * selfActor, UPrimitiveComponent * otherActor, FVector normalImpulse, const FHitResult& hit) {
	UE_LOG(LogSomething, Warning, TEXT("hit man down"));
}


void MyChar::onSomethingOverlap(UPrimitiveComponent* overlappedComponent, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult &sweepResult) {
	UE_LOG(LogSomething, Warning, TEXT("overlap"));
}

My Pawn collision profile is: Pawn and other actor that is hitting my pawn is WorldDynamic. that i wanna do is when actor hit my pawn to register event on my pawn and do staff in code.

what i’m missing in here?

restarting editor solved the problem… no idea why but everything worked perfectly after restarting the ue4 editor.i guess hot reloading is not doing it’s job enough…

this is the result: https://www.youtube.com/watch?v=8kImS3Yo85k