I have a simple grenade actor that is created after shooting a grenade launcher.
After 2 seconds or hitting an enemy, it plays an explosion particle and deletes itself via Destroy();
However, that destroy returns false, the actor is not deleted, and just stays in memory forever, with it’s tick function always running. Why is this happening?
Sure, here’s the main code. Things like this have always worked in the past, unsure why it’s not now.
void ABulletPhysics::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
//2 second timer before exploding on it's own
if (ExplodeTimer > 0) {
ExplodeTimer -= DeltaTime;
if (ExplodeTimer <= 0) {
Explode();
}
}
//Just checks if it hit an enemy
FHitResult hit = ScanHit(5);
if (hit.GetActor()) {
Explode(hit.GetActor());
}
}
void ABulletPhysics::Explode(AActor* hitActor) {
if (HitParticle) {
UNiagaraComponent* comp = UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), HitParticle, GetActorLocation(), FRotator::ZeroRotator);
}
//Deactivates the trail effect
Particle->Deactivate();
///[Todo] this destroy doesn't work for some reason
Destroy();
}