Hello everyone!
I have a character class with following constructor:
ACharacter2D::ACharacter2D()
{
PrimaryActorTick.bCanEverTick = true;
Capsule = CreateDefaultSubobject<UCapsuleComponent>(TEXT("RootCapsule"));
Capsule->bGenerateOverlapEvents = true;
Capsule->SetNotifyRigidBodyCollision(true);
Capsule->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
Capsule->SetCollisionObjectType(ECC_Pawn);
Capsule->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block);
Capsule->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
Capsule->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
Capsule->OnComponentHit.AddDynamic(this, &ACharacter2D::OnHit);
RootComponent = Capsule;
Movement = CreateDefaultSubobject<USimple2DMovement>(TEXT("2DMovement"));
Movement->UpdatedComponent = RootComponent;
AutoPossessPlayer = EAutoReceiveInput::Player0;
}
Function OnHit, that is binded to OnComponentHit, is defined as follows:
void ACharacter2D::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
UE_LOG(LogClass, Warning, TEXT("Hit!"));
}
I constructed test level with blocks consisting of simple square sprites with following collision properties:
The thing is that this setup does not work at all.
Event is being triggered neither by stepping on blocks nor by jumping or running into them.