We are creating a simple game with a few particle effects that are spawned based on some events (explosions for projectiles or death particles for some enemies), recently we started to test our game in Android (Shipping and Development) and we have found that, if a particle system is spawned for the first time, it will cause the screen to freeze for a second or more. After the first spawn, we can spawn as many particles (being the same particle already spawned) as we want without that freeze occurring again.
We tested again using an empty project (C++ Side Scroller template), and we added a simple particle system (the default created in the editor). Then we added the event that when the user touches the screen it should spawn and we have found that the freeze still occurs.
One solution we have thought of, but it sounds a bit weird and impractical in a larger scale is to reproduce all of those effects at the beginning of the game with a loading screen to hide/show the freeze. But this fix will force us to keep track of every particle/effect created and add it into a list.
Is it possible that there is another solution for this problem?
We are using:
Unreal Engine 4.4.1
Visual Studio 2013 Express
Windows 7
Galaxy S4 International version (Non-LTE)
Include file:
UPROPERTY(EditDefaultsOnly, Category = "FX Test")
UParticleSystem* TestFX;
UPROPERTY(EditDefaultsOnly, Category = "FX Test")
FVector TestFXLocation;
UPROPERTY(EditDefaultsOnly, Category = "FX Test")
float TimeToHide;
protected:
/** Handle touch inputs. */
void TouchStarted(const ETouchIndex::Type FingerIndex, const FVector Location);
void EnableParticle();
void DisableParticle();
UPROPERTY(Transient)
UParticleSystemComponent* TestFXPSC;
};
Source file:
void AParticleTestCharacter::TouchStarted(const ETouchIndex::Type FingerIndex, const FVector Location)
{
EnableParticle();
}
void AParticleTestCharacter::PostInitializeComponents()
{
Super::PostInitializeComponents();
if (TestFXPSC == NULL)
{
TestFXPSC = UGameplayStatics::SpawnEmitterAtLocation(this, TestFX, TestFXLocation, FRotator::ZeroRotator, false);
if (TestFXPSC)
{
TestFXPSC->bOwnerNoSee = false;
TestFXPSC->bOnlyOwnerSee = false;
TestFXPSC->DeactivateSystem();
}
}
}
void AParticleTestCharacter::EnableParticle()
{
if (TestFXPSC)
{
TestFXPSC->ActivateSystem(true);
GetWorldTimerManager().SetTimer(this, &AParticleTestCharacter::DisableParticle, TimeToHide);
}
}
void AParticleTestCharacter::DisableParticle()
{
if (TestFXPSC)
{
TestFXPSC->DeactivateSystem();
}
}