- Home /
How to trigger particle effect
like this iam making ball game 2d for mobile and when i die when i fall into hole i want to spawn particle like blood or something how can i make on trigger particle system ?
Answer by SantosR · Apr 07, 2015 at 06:59 PM
Untick the loop property in the particle settings and use the Emit()
method
http://docs.unity3d.com/ScriptReference/ParticleSystem.Emit.html
Actual implementation depends on what kind of effect you have, but on your case you will most likely look like this:
MyParticleSystem.Emit(50);
Play a little bit with the particle system in the inspector till you have the effect you want and you only need to pass the number of particles to spawn as argument.
Answer by DoTA_KAMIKADzE · Apr 07, 2015 at 03:44 PM
[SerializeField]
protected GameObject thisobjectBlood;
private void OnTriggerEnter2D(Collider2D colidedObj)
{
if (colidedObj != null) //check for tags or whatever else that can hit this object
{
//now if this is a thing that can hit your object:
//if for this object:
Instantiate(thisobjectBlood, thisTransform.position, thisTransform.rotation);
//if(outOfHealth) Destroy(gameObject); //and for example instantiate explosion or whatever
//you can do the same for collided object here or in the object itself depending if can be destroyed by this object
}
}
Your answer
Follow this Question
Related Questions
How do I config NGUI screen to fit Mobile device? 2 Answers
Android Game not working 2 Answers
Wp8 an Android 0 Answers
mobile app crash 0 Answers