Ok, so I have the following:
Projectile.cpp
void AProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
// Only add impulse and destroy projectile if we hit a physics
if ((OtherActor != NULL) && (OtherActor != this) && (OtherComp != NULL))
{
if (OtherComp->IsSimulatingPhysics())
{
OtherComp->AddImpulseAtLocation(GetVelocity()*ImpulseMultiplier, GetActorLocation());
}
LaunchBlast->Deactivate();
ImpactBlast->Activate();
Sphere->DestroyComponent();
CollisionComp->DestroyComponent();
UGameplayStatics::ApplyPointDamage(OtherActor, ProjectileDamage, GetVelocity().GetSafeNormal(), Hit, GetInstigatorController(), this, UDamageType::StaticClass());
}
FTimerHandle TimerHandle;
GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &AProjectile::DestroyProjectile, SelfDestructDelay, false);
}
void AProjectile::DestroyProjectile()
{
this->Destroy();
}`Preformatted text`
Cannister.cpp
float ACannister_CPP::TakeDamage(float DamageAmount, FDamageEvent const & DamageEvent, AController * EventInstigator, AActor * DamageCauser)
{
UE_LOG(LogTemp, Warning, TEXT("Damage Received %f"), DamageAmount)
TArray<AActor*> ignoredActors;
Hitpoints = Hitpoints - DamageAmount;
DamageFire->Activate();
if (Hitpoints <= 0)
{
ExplosionBlast->Activate();
UGameplayStatics::ApplyRadialDamage(
GetWorld(),
CannisterDamage,
GetActorLocation(),
Radius,
UDamageType::StaticClass(),
ignoredActors,
this,
nullptr,
false,
ECollisionChannel::ECC_Visibility);
CannisterMesh->DestroyComponent();
FTimerHandle TimerHandle;
GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ACannister_CPP::DestroyCannister, SelfDestructDelay, false);
}
return 0.0f;
}
After playing yesterday around with these functions, both in C++ and BP, I suspect that it might have something to do with the location/origin where I am applying the radial damage and the EcollisionChannel.
Could it be that by applying the radial damage at the actor location, I am applying it from “within” or under the canister, so it actually gets blocked by the canister mesh due to the “ECollisionChannel::ECC_Visibility” ? Unfortunately I did not have yet the time to test this latest theory.
Cheers,
Denis