- Home /
Death with particle effect.Still need Help!
Hi guys,im making roll the ball game,anyway when my ball falls off from level,it gets destroyed,or when im hiting some obstacles it gets destroyed too.Well I want to make it better,i want particle effect plays when i get destroyed-(''Dead''),(particle effect plays just some seconds when i get destroyed). Please help me at this.Thanks for attention :)
Answer by FLASHDENMARK · Jun 28, 2012 at 09:01 AM
Use the Instantiate command, when the ball gets destroyed.
Answer by Tim-Michels · Jun 28, 2012 at 09:14 AM
You add a ParticleEffect to your scene, but you disable emitting. (particleEmitter.emit = false;)
Now, when you want the particle to show, you simple set particleEmitter.emit = true; If the particle needs to follow your ball, you could add the particle as a child of the player. That way the effect will always follow your player.
Also experiment with the simulation space. If you want your particles to actually animate in world space, you will need to set it that way.
If the simulation space of the particle is set to local, and your ball moves while emitting, the particle will not emit in a realistic way because it is moved.
Experiment with this stuff and you can create some really cool effects for your ballgame.
Cheers ;)
particleEmitter.emit = true; on Death? it is only enabling particle effect,but how to add it? I dont understand.
Well, if you don't have a particle-effect in your scene, you will need to Instantiate a particle prefab.
Here's a small example: (C#)
public GameObject ExplosionPrefab;
void OnDeath()
{
GameObject explosion = Instantiate(ExplosionPrefab) as GameObject;
explosion.particleEmitter.emit = true;
}
The public gameobject 'ExplosionPrefab' should be assigned in your scene with a self-made particle prefab, or one of the Unity standard particles.
Instantiate essentially creates a new instance of something you want to create at runtime.
Answer by Dreatix · Jun 28, 2012 at 03:53 PM
Here is my Death script:
public void Death()
{
audio.clip = DestroySound;
audio.Play();
Time.timeScale = 0f;
death = true;
}
}
An there is second death script:
if (other.tag == "Destroy")
{
_GameManager.GetComponent<GameManager>().Death();
Destroy(gameObject);
}
I Dont know how to modify it like as your example,so can you please help me to do this? Pay attention on time scale,i want that time scale dont affect the particle effect,but i also want it Of.
Answer by NoizTank · May 07, 2015 at 06:26 AM
Hey guys, I'm still relatively new to C# and Unity as a whole, but I'm making a simple 2D game and I solved the problem of death effects by adding an empty game object into my scene called DeathEffect, then creating a prefab of it. I then attached this code to my player:
public GameObject deathEffect;
void OnCollisionEnter2D(Collision2D col){
if (col.gameObject.name == "FlyingSquid") {
Instantiate (deathEffect, col.gameObject.transform.position, col.gameObject.transform.rotation);
Destroy (col.gameObject);
}
}
Then I just stuck my DeathEffect object into the public GameObject deathEffect slot on my script component. I hope this noob knowledge helps someone:)
Answer by guinoalaskapp · Jun 08, 2021 at 03:11 AM
No no no, I have the same problem, but I need to:
1: disable my 2d sprite renderer 2: play the particle effect 3: wait until particles gone 4: reset players position and also entire map "running" stuff
All of those things i can do, my isue is:
1: it dont disable the sprite renderer 2: it plays the particke effect to late 3: it never wait, it restart instantly dies and then display particles 4: it restet the player position, but again, instantly
Your answer
![](https://koobas.hobune.stream/wayback/20220613073414im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
c# play particle effect on key press? 1 Answer
Weird GUILayout Scrollview Behavior 0 Answers
hide object start script 4 Answers