Bug Report: Destroyed Particle Component emitting particles from other random systems

Hey guys.

I’ve currently implemented a system to spawn and destroy blueprint actors when entering and leaving an area in C++.

Due to this system, I have come across a strange bug with particle systems.

We have created a blueprint containing a particle system and a sound component. Nothing else.

If the actor is destroyed off camera, (Because we left the range) Particles from a completely different Particle system spawn where the actor was.

It seems to do it at a random destroyed object, but tends to happen on the last destroyed one most often.

The actor does get destroyed correctly as it is no longer in the level.

The particles we generally see are from systems created on animation notifiers. (On a character wandering around the level.)

Destroying the component in blueprints doesn’t make a difference. Even if i disable/hide the component beforehand.

Below is the code i’m using to spawn/destroy the blueprint:

In the .h:

private:
	UPROPERTY(Transient)
	TWeakObjectPtr<class AActor> SpawnedActor;

	UPROPERTY()
	bool bDidSpawn;

In the .cpp:

void ASubmergedSpawnerActor::SpawnObject( UBlueprint* BlueprintRequested )
{
	FVector Location = this->GetActorLocation();
	FRotator Rotator = this->GetActorRotation();

	// Spawn the blueprint here.
	FActorSpawnParameters SpawnParams;
	SpawnParams.Instigator = NULL;
	SpawnParams.bDeferConstruction = false;

	SpawnedActor = GetWorld()->SpawnActor( BlueprintRequested->GeneratedClass, &Location, &Rotator, SpawnParams );
	bDidSpawn = true;
}

bool ASubmergedSpawnerActor::DespawnObject()
{
	bool bReturnValue = bDidSpawn;

	bDidSpawn = false;

	if (SpawnedActor.IsValid())
	{
		bReturnValue = SpawnedActor->Destroy() || bReturnValue;
		SpawnedActor = NULL;
	}
	
	return bReturnValue;
}

Any help/fix would be appreciated.

Hey FacePalm.exe -

From what you are describing it doesn’t sound like your Spawning Particles are a problem, but the particle system which you have attached to the wandering character. We’ve had users in the past where animnotified particle systems are spawning at an incorrect point? Could this be to what you are referring or am I missing something? If possible a video example of some screenshots would be helpful.

Thank You

Eric Ketchum

Hi FacePalm.exe,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.

Eric Ketchum

Hi Eric,

I’ve created a video of what i’m seeing: - YouTube
It’s not the system itself, but a bunch of particles from the same system. (as both are visible)
As you can see in the Actor list, the Gnat system is created and then destroyed, but water spray particles spawn from it’s old position.
This only happens once the Gnat system is destroyed.
And if the gnat’s spawner’s position is moved, the stray particles then spawn from that point, so it’s position isn’t random, but based on the location of the destroyed actor/system.

Cheers

I actually commented above, on an older version of the page, so I did not notice this.
See post above for details.

Hi FacePalm.exe -

Ok just so I can make sure that I get teh reproduction correct. You have a particle system which is contained in a blueprint which the BP is then spawned via C++ code into the level and then destroyed. However, another unrelated Particle System (? also in a Blueprint) is spawning in both it called location and in the location of the recently despawned Gnat BP system.

Thanks for the clarification -

Eric Ketchum

EDIT: Can you also try removing the Gnat Particle System from the BP, does the Spout still spawn where the BP is just destroyed?

Thanks Again

Yes that’s correct. The unrelated Particle System is spawned off an animation notifier on a blueprint. (The whale swimming around.)
The rest is spot on.

And I just tested removing the gnat Particle system from the BP, and it does stop the issue from happening, so it is related to the destroyed object containing a Particle System.

Hey FacePalm.exe -

One last question in the Whale’s anim notify are you assigning a bone for the socket and if not how are you setting the emitter’s location?

Thank You

Eric Ketchum

There are various sockets on the whale mesh, For example the Water Spout system we have a socket named “Water_Spout” which is attached to “Bone008”.
So we are attaching it to the “Water_Spout” socket, not the bone.

The Particle System isn’t being offset or rotated in the anim notifier either, if that helps.

Hey FacePalm.exe

Sorry for the delay getting back to you. We are still testing trying to reproduce your spawning issue. I wanted to ask if the Whale is spawned in code as well as the Gnats of if it just exists in a Blueprint. If it is spawned through code could your post the relevant snippet for us to look through

Thank You

Eric Ketchum

Hi there Eric,

The whale is also spawned in code. It is an actor derived class which I have created a blueprint of, and then spawn into the level.

It’s spawned using the following:

void ASubmergedAmbientAISpawnActor::SpawnAI( UBlueprint* NewAI, ESubmergedAmbientCreatureType::Type AIType )
{
	FVector Location = this->GetActorLocation();
	FRotator Rotator = this->GetActorRotation();

	// Give us some random rotation
	Rotator.Yaw += FMath::FRandRange( MinSpawnRotationYaw, MaxSpawnRotationYaw );

	// Spawn the blueprint here.
	FActorSpawnParameters SpawnParams;
	SpawnParams.Instigator = NULL;
	SpawnParams.bDeferConstruction = false;

	SpawnedActor = GetWorld()->SpawnActor( NewAI->GeneratedClass, &Location, &Rotator, SpawnParams );

	if (SpawnedActor.IsValid() && AIType != ESubmergedAmbientCreatureType::None)
	{
		ASubmergedAmbientCharacter* NewChar = Cast<ASubmergedAmbientCharacter>(SpawnedActor.Get());
		NewChar->SetAmbientAnims(AIType);

		if (OverridenEscapeValue > 0)
			NewChar->SetEscapeRange( OverridenEscapeValue );

		if (TargetPathNode != NULL)
		{
			NewChar->SetTarget(TargetPathNode, true);
		}
	}
}

As you can see, if it spawns successfully I setup multiple animations on the spawned actor using the following:

void ASubmergedAmbientCharacter::SetAmbientAnims(ESubmergedAmbientCreatureType::Type CreatureType, bool KillOnDespawn/*=true*/)
{
	for (int i = 0; i < CreatureData.Num(); ++i)
	{
		if (CreatureData[i].AmbientSpawnType == CreatureType)
		{
			DespawnAnim = CreatureData[i].DespawnAnim;
			IdleAnim = CreatureData[i].IdleAnim;
			SpawnAnim = CreatureData[i].SpawnAnim;
			EscapeRange = CreatureData[i].EscapeRange;

			break;
		}
	}
}

Which i then pass to the anim BP and do the following:

Hopefully that helps.

Hey FacePalm.exe -

Thank You for that it was very helpful. Unfortunately I still have not been able to reproduce what you are seeing. I was wondering if you could recreate this issue in a sample code project. You can message me via the forums if you would like to keep assets or code private.

Thank you and in the meantime I will continue to dig into this reproduction.

Eric Ketchum

So the problem seems to have fixed itself when we updated to 4.5.1. (We were working in 4.4.1)

I can no longer reproduce the issue, so I’m not sure if it was a bug in 4.4.1 that has been fixed, or whether something else has changed which has covered up the issue. (i just spent a bunch of time creating a demo project, and then found out it doesn’t happen. -_- oh well.)

I’m afraid i didn’t actually check it was still happening before posting more info the other day, sorry about that.

I’m not sure what specific bugs were fixed going from 4.4.1 to 4.5.1, but hopefully a proper fix for this issue was among them.

Sorry for the run around, and cheers again.