Dear experts,
I have the following code in “Projectile.cpp” for the OnHit method:
void AProjectile::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
LaunchBlast->Deactivate();
ImpactBlast->Activate();
ExplosionForce->FireImpulse();
SetRootComponent(ImpactBlast);
CollisionMesh->DestroyComponent();
//also get rid of projectile objects in the world
FTimerHandle Timer;
GetWorld()->GetTimerManager().SetTimer(Timer, this, &AProjectile::OnTimerExpire, DestroyDelay, false);
}
However when I fire the projectiles are not destroyed on impact. They keep sitting there and then disappear abpruptly once the .SetTimer() method kicks in after 10 seconds.
I have tried troubleshooting and using different methods instead of DestroyCompnent() but I can’t get it to work. I tried “DestroyPhysicsState”, “DestroyComponent(true)”.
In the Projectile_BP I unticked the “CollisionMesh” --> “Visible” but when I play I can still see the M_Metal_Rust Mesh when I shoot.
I am on version 4.22.
Any ideas are highly appreciated.
Thank you,
Peter