So I’ve been trying to get collision to work when the 2D player character lands on the ledges, or hits his head on a ledge (when jumping from below a ledge). Googled quite a few methods:
I started a brand new project and in the constructor of the MyProjectCharacter.cpp, I have:
GetCapsuleComponent()->OnComponentBeginOverlap.AddDynamic(this, &AMyProjectCharacter::OnOverlapBegin);
GetCapsuleComponent()->OnComponentHit.AddDynamic(this, &AMyProjectCharacter::OnThisHit);
OnActorHit.AddDynamic(this, &AMyProjectCharacter::OnHitActor);
And I have these functions set up:
void AMyProjectCharacter::OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
UE_LOG(LogTemp, Error, TEXT("Collision detected 1"));
}
void AMyProjectCharacter::OnThisHit(AActor *SelfActor, UPrimitiveComponent *OtherActor, FVector NormalImpulse, const FHitResult& Hit)
{
UE_LOG(LogTemp, Error, TEXT("Collision detected 1a"));
}
void AMyProjectCharacter::OnHitActor(AActor *SelfActor, AActor *OtherActor, FVector NormalImpulse, const FHitResult& Hit)
{
UE_LOG(LogTemp, Error, TEXT("Collision detected 1b"));
}
void AMyProjectCharacter::ReceiveHit(class UPrimitiveComponent * MyComp, AActor * Other, class UPrimitiveComponent * OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult & Hit)
{
UE_LOG(LogTemp, Error, TEXT("Collision detected 1c"));
}
But none of these functions get called. Any idea what I’m missing?