Function when actor collides

For a projectile, I need to get whenever my projectile hits any other object.

Fist I tried to use

MeshComponent->OnComponentHit.AddDynamic(this, &AProjectile::OnHit);

Unfortunately this is extremely unreliably (It only works when my projectile hits certain parts of my NPCs to be exact)

Then I tried to use the ReceiveHit-function like this:

void AProjectile::ReceiveHit(class UPrimitiveComponent * MyComp,
class AActor * Other,
class UPrimitiveComponent * OtherComp,
	bool bSelfMoved,
	FVector HitLocation,
	FVector HitNormal,
	FVector NormalImpulse,
	const FHitResult & Hit)
{
	Super::ReceiveHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit);
	GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Green, "ReceiveHit() Called");
}

But it is never called.

What am I doing wrong? How do I do this properly?

I also posted a thread in the forum, in case you need more information:

Rather than binding an even to the component, I’d use overlap events. Look for

void ReceiveActorBeginOverlap(AActor* Other)

I don’t need to get when it overlaps though but when my projectile actually collides with another actor. I have collision enabled on my projectile but still need to have some functionality when it hits another actor if this makes more sense.

Overlaps are collisions

Of course they are collisions, but not the ones I need right now :slight_smile:

I have a projectile with simulate physics and blocking-collision enabled. Now I need to get when it hits another actor. When it bounces off a wall for example. ReceiveActorBeginOverlap doesn’t fire in this case.