Projectiles Will Not Explode When Hit the Walls

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

It’s hard to tell from the screenshot, is that the whole projectile or just the particle effect?

I believe it would be best if you zip up your project file, upload it to any cloud storage platform (Google Drive), and share the link with us. so that we would be able to search through your project.

Make sure you zip up your project file this way:-

The Projectile, I tested it

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms