Unity3D - Replay a non-looping Particle System

2019-03-01 09:51发布

I'm following the Survive Shooter Unity3D tutorial and have come across several inconsistencies between the Unite Day presentation and actual behavior in Unity 5.3, such as animation transition and other small issues I had to figure out to achieve the desired gameplay result and follow the tutorial.

One issue I'm unable to resolve is replaying a non-looping particle system. In the game hit particles are emitted whenever an enemy is shot, but when running the game these particles are emitted once and not upon following hits.

This is the particle system configuration:

enter image description here

The original code simply re-positions and re-plays the emission:

// Set the position of the particle system to where the hit was sustained.
hitParticles.transform.position = hitPoint;

// And play the particles.
hitParticles.Play();

I've tried resetting and clearing the system but that didn't work:

hitParticles.Clear();
hitParticles.time = 0;
hitParticles.Play();

How do I replay the particle emission?

thanks!

3条回答
Lonely孤独者°
2楼-- · 2019-03-01 10:31

To reply the ParticleSystem try to use ParticleSystem.Emit(...) with parameters that suits your animation like:

hitParticles.Emit(5);
查看更多
虎瘦雄心在
3楼-- · 2019-03-01 10:33

If you're using Unity 5.3.1, then it sounds very much like a bug(http://issuetracker.unity3d.com/issues/particle-system-plays-only-once).

查看更多
Animai°情兽
4楼-- · 2019-03-01 10:41

If you need to reset immediately Particle system and repeat it (For example Rifle barel explosion) I would recommend you this:

ShootParticles.Simulate( 0.0f, true, true );
ShootParticles.Play();
查看更多
登录 后发表回答