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: