Hey, I am running in to a type of bug I think. Not sure what’s going on here but my OnHit function in my game is giving unexpected results. When the enemies shoot me, my player pawn takes the damage. But when I shoot the enemy the OnHit is not registered. I will include the snippet of my code, not sure what I am doing wrong here. I have the same collision settings on both Actors. Actors do generate Overlaps when the projectile hits them but the OnHit function isn’t called.
void AProjectile::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
Blast->Deactivate();
Impact->Activate();
Force->FireImpulse();
SetRootComponent(Blast);
CollisionMesh->DestroyComponent();
FTimerHandle Timer;
UGameplayStatics::ApplyRadialDamage(
this,
Damage,
OtherActor->GetActorLocation(),
Force->Radius, //Bound together for consistency
UDamageType::StaticClass(),
TArray<AActor*>() //Damage all actors
);
UE_LOG(LogTemp, Error, TEXT("I hit ->%s"), *(OtherActor->GetName()));
//GetWorld()->GetTimerManager().SetTimer(Timer, this, &AProjectile::OnTimerExpire, DestroyTime, false);
//GetWorldTimerManager().SetTimer(Timer, this, &AProjectile::OnTimerExpire, DestroyTime, false);
}
EDIT:
Looks like only the Projectile Blueprint class for the Enemy was working. So I had to duplicate it, make the needed changes and delete the old ones. But now everything is working as intended. This is the second time in Unreal I had to delete the Blueprint of a parent C++ class and recreate it to get it working as intended. Is this a caching issue?