- Home /
Particle Effect Script Help
How would I change this script so that when my cannonball prefab collides with something that has a tag of "enemy" it will spawn a blood splat particle effect, and if it collides with anything else it spawns a explosion particle effect?
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.CompareTag("enemy"))
// trigger the blood splatter effect
else
// trigger the explosion effect
}
Answer by conflictbliz · Oct 22, 2011 at 10:45 PM
so you want it to have a effect that shows blood when hit with an enemy and then a effect that shows an explosion when hitting the ground i would make 2 separate scripts one for the enemy tag and one for the ground tag
Explosion and splatter effects are just one-shot particle effects, maybe with an audio source. $$anonymous$$ake a prefab with the effect in it, instantiate the prefab when you want it to appear.
Also, @conflictbliz? Please include punctuation in your answers. It's kind of useful.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Particle Effects Script 1 Answer
Another Scripting Question 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
accessing a variable from one script in another with Unity 1 Answer