How can I Destroy a projectile on collision? C++

I have simple shooter made off the C++ first person shooter tutorial with a few edits. Problem is I can’t get the Projectiles to destroy themselves on collision. The result is a cube getting hit by the same “bullet” multiple times and attempting to break the sound barrier.

The collision Code:

void AProjectile::OnHit(UPrimitiveComponent * HitComponent, AActor * OtherActor, UPrimitiveComponent * OtherComponent, FVector NormalImpulse, const FHitResult & Hit)
{

if (OtherActor != this && OtherComponent->IsSimulatingPhysics())
{	
	OtherComponent->AddImpulseAtLocation(ProjectileMovementComponent->Velocity, Hit.ImpactPoint);
	Destroy();
}

}

What should I do to get the projectiles to destroy on collision?

My guess is that you’re having an external issue. Try recompiling; Epic games ensured that calling Destroy() determines the correctness of the invariant: no Tick-like functionality is allowed after calling Destroy(), thus making the AActor garbage-collectible. You can call AActor::IsPendingKill() to check if Destroy is called. However, you should first separate the if conditions and ensure(…) them both(or use VS debugger) to see if Destroy() is actually called.

Seem to have found the problem. Was pretty sure the FPS tutorial was telling me to set the Simulation Generates Hit Events onto the mesh of the projectile which was slightly larger than the collision component. this seems to make it so that when it collides with something no code would execute because the mesh didn’t have code connected to it, and the mesh would always prevent the collision component from colliding. Hopefully this can help someone else out.