x


unity to determine the number of collisions

I want to make enemies enemy encounter objects Player, when the enemy to enemy collision objects Player three times, the object is converted to an object thing Player

Will the program how to write?

**var thing ;
function OnCollisionEnter(theCollision : Collision){
    if(theCollision.gameObject.name == "enemy"){

 Destroy(gameObject);
 Instantiate(thing,transform.position,transform.rotation);


    } else if(theCollision.gameObject.name == "PC"){
         Debug.Log("Nothing");
        }
}**
more ▼

asked Apr 15 '11 at 10:58 AM

shelin gravatar image

shelin
10 17 20 24

Can you rephrase the question please? To many grammar errors to understand it for me... Not to be rude, sorry. Did you want it so that when an enemy hits/collides with a Player, it changes in to thing....?

Apr 15 '11 at 12:32 PM Justin Warner
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

you could try something like this...

var thing;

function OnCollisionEnter(theCollision : Collision){    
     var clone = Instantiate(thing,transform.position,transform.rotation);
     Physics.IgnoreCollision(clone.collider, collider);
     Destroy(gameObject); 
} else if(theCollision.gameObject.name == "PC"){
     Debug.Log("Nothing");
}

what your issue could have been is that you distroyed the GameObject before you instantiated the "thing" object.

more ▼

answered Apr 15 '11 at 01:12 PM

pdh1kid gravatar image

pdh1kid
54 8 9 13

I want to an enemy hit player . Player can change the other cube(d).

I can enemy hit player ,than player destory.but I cannot change cube(d). Will the program how to write?

Apr 16 '11 at 08:53 AM shelin
(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:

x124

asked: Apr 15 '11 at 10:58 AM

Seen: 547 times

Last Updated: Apr 15 '11 at 10:58 AM