Duplicating [this][1] question.
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 with OnComponentHit.AddDynamic, 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:
216401-
Whatever I do, hit event just never triggers. I tried moveing my character with
MoveUpdatedComponent(DesiredMovement * DeltaTime, UpdatedComponent->GetComponentRotation(), true, &Hit, ETeleportType::None)
and
UpdatedComponent->SetLocation(UpdatedComponent->GetLocation()+ DesiredMovement * DeltaTime);
Tried dropping physics simulated object on my character, still no luck. Object gets blocked, event doesn’t occur.
Does anyone have any idea how to fix this?