x


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);
        }
}
more ▼

asked Apr 14 '11 at 02:54 AM

beattonick 4 gravatar image

beattonick 4
11 5 5 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Apr 14 '11 at 03:16 AM

Justin Warner gravatar image

Justin Warner
6.3k 19 27 65

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5081
x2497
x440
x100

asked: Apr 14 '11 at 02:54 AM

Seen: 1044 times

Last Updated: Apr 14 '11 at 02:54 AM