When the Turrents hit the Walls that separate them, When they shoot the wall, The projectile Does not disappear, seen in this screenshot
Here is the code to my OnHit Function
void AProjectile::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
auto MyOwner = GetOwner();
if (MyOwner == nullptr && OtherActor == nullptr && OtherComponent == nullptr)
{
Destroy();
return;
}
auto MyOwnerIns = GetInstigatorController();
auto DamageTypeClass = UDamageType::StaticClass();
if (OtherActor != nullptr && OtherActor != this && OtherActor != MyOwner)
{
UGameplayStatics::ApplyDamage(OtherActor, Damage, MyOwnerIns, this, DamageTypeClass);
if (HitParticles)
{
UGameplayStatics::SpawnEmitterAtLocation(this, HitParticles, GetActorLocation(), GetActorRotation(), true);
}
}
Destroy();
}
Edit: I had to add the other components or it would crash, lol