I have a Well and as a child a particle system of water splashing.
If I click the well, it plays an animation (gets bigger then smaller) and then plays my particle system which is the water splashing.
However, If i hold down the mouse the particlesystem continuously plays, and if i do OnMouseButtonDown it doesnt play at all. The thing is, you will be clicking the well very often, (spam clicking for water) now is it better to instantiate the particleFX for x Time then delete it after y Time? or what should I do, and preferably how?
public class ClickAnimation : MonoBehaviour
{
public GameObject MyAnimatorObject;
private Animator myAnimator;
public bool waterPlay;
public ParticleSystem waterFountain;
void Start ()
{
myAnimator = MyAnimatorObject.GetComponent<Animator> ();
}
void Update ()
{
if (waterPlay)
{
waterFountain.Play ();
waterFountain.GetComponent<ParticleSystem>().enableEmission = true;
}
else if (!waterPlay)
{
waterFountain.Stop();
}
}
void OnMouseDown()
{
myAnimator.Play ("WellClicked");
waterPlay = true;
}
void OnMouseUp()
{
waterPlay = false;
}
}
A clicker game with a chest, each time u click on it, the chest shakes (plays the animation) and has few coins from the Particle system fall out, lets say 3-4 coins (predetermined in the settings of the particle system)
In my case its just a fountain and water splashing out
But each time it gets a click, I guess it would be nicer to finish the particlesystem going on (e.g. the 3-4 coins falling out) and let an extra 3-4 fall out.
(PS: this is not like a normal clicker, so you dont click the “coins” or water to pick up later. hence the reason why i am using a particle system and not gameObjects.)
I would use one particle system. I would turn off envision. Then I would call ParticleSystem.Emit on each click. I think that will suit your needs better.