OnActorHit not being called

Hello,

I am making a bullet actor for my game and am having issues with detecting when it hits an object, the OnActorHit event is not being called.
Here is the code for the ABullet class:



#include "Bullet.h"

#define AIM_TRACE ECC_GameTraceChannel1
#define DMG_TRACE ECC_GameTraceChannel2
#define BULLET_CHANNEL ECC_GameTraceChannel3


const float ABullet::BulletSpeed = 2000.0f;

// Sets default values
ABullet::ABullet()
{
	const ConstructorHelpers::FObjectFinder<UStaticMesh> CapsuleMesh(TEXT("/Game/StarterContent/Shapes/Shape_NarrowCapsule.Shape_NarrowCapsule"));
	const ConstructorHelpers::FObjectFinder<UMaterial> BulletMaterial(TEXT("/Game/Materials/Weapons/Bullet.Bullet"));

	Bullet = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Bullet"));
	Bullet->CastShadow = false;
	Bullet->SetStaticMesh(CapsuleMesh.Object);
	Bullet->SetMaterial(0, BulletMaterial.Object);
	Bullet->SetWorldScale3D(FVector(0.25f, 0.25f, 0.25f));
	Bullet->AddRelativeRotation(FRotator(-90.0f, 0.0f, 0.0f));

	Bullet->SetCollisionObjectType(BULLET_CHANNEL);
	Bullet->SetCollisionResponseToChannel(AIM_TRACE, ECR_Ignore);
	Bullet->SetCollisionResponseToChannel(DMG_TRACE, ECR_Ignore);
	Bullet->SetCollisionResponseToChannel(BULLET_CHANNEL, ECR_Ignore);

	RootComponent = Bullet;

	SetActorEnableCollision(true);
	OnActorHit.AddDynamic(this, &ABullet::OnHit);

	MovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovement"));
	MovementComponent->InitialSpeed = BulletSpeed;
	MovementComponent->MaxSpeed = BulletSpeed;
	MovementComponent->Velocity = FVector(0.0f, 0.0f, 1.0f);
	MovementComponent->ProjectileGravityScale = 0.0f;
}

void ABullet::OnHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit)
{
	Destroy();
	UE_LOG(LogTemp, Warning, TEXT("Hit!"))
}


Why isn’t OnHit being called? I know the collisions are working because the bullet is stopping when it hits something.
Thanks in advance.

Do you have an UFUNCTION() macro in the header above the definition of the OnHit function?

Thanks, that fixed my issue.