- Home /
spawning on collision
im doing a script for when a bullet hit an enemy it will damage the enemy and at the same time it will spawn a particle systeme (like blood)i aready done the part where it damage the enemy and kill him but i dont know how to spawn the particle systeme. can you help me.
here is my script:
var hitPoints = 1; var bulletDamage = 1;
 
               function OnCollisionEnter(coll:Collision){ 
if(coll.gameObject.tag=="bullet") { hitPoints -= bulletDamage; }
 if (hitPoints <=0){ Destroy(gameObject); } }  
Answer by Justin Warner · Apr 14, 2011 at 03:16 AM
var hitPoints = 1; var bulletDamage = 1;
function OnCollisionEnter(coll:Collision){
 if(coll.gameObject.tag=="bullet") { hitPoints -= bulletDamage; }
if (hitPoints <=0){
  Destroy(gameObject);
  //Instantiate
}
}
http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html
Use something off this... It'll give you the main idea as to how to do this.
http://unity3d.com/support/documentation/Manual/Instantiating%20Prefabs.html
For more reading.
Your answer
 
 
             Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
C# GameObject is not detecting collision with Character Controller 2 Answers
Collision problem when spawning in the collider 1 Answer
Getting radius of a sphere 2 Answers
Spawning a new sphere when 2 other spheres collide. 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                