2

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!

BarakChamo
  • 3,321
  • 5
  • 30
  • 38

3 Answers3

2

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

hitParticles.Emit(5);
Jerry Switalski
  • 2,690
  • 1
  • 18
  • 36
0

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).

RPGamer
  • 1
  • 2
  • Thanks @RPGamer, at least I know it's bug, there have been other bugs popping up throughout following the tutorial but at least I know it's my code to blame with this issue. – BarakChamo Jan 19 '16 at 13:23
0

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();
Jakub Kučera
  • 558
  • 4
  • 21