问题
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:
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!
回答1:
To reply the ParticleSystem
try to use ParticleSystem.Emit(...)
with parameters that suits your animation like:
hitParticles.Emit(5);
回答2:
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).
回答3:
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();
来源:https://stackoverflow.com/questions/34856642/unity3d-replay-a-non-looping-particle-system