- Home /
I want to A(enemy) touch B. Then B change to C
I want to A(enemy) touch B. Then B change to C
this is my script.
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"); } }
My enemy touch B(gameObject) only destroy B(gameObject) It cannot change C
Answer by efge · Apr 13, 2011 at 09:06 AM
Destroy(gameObject) also destroys the attached script, so you should call Instantiate() before Destroy().
Answer by shelin · Apr 14, 2011 at 03:26 AM
I call Instantiate() before Destroy(). But My enemy touch B(gameObject) only push slowly B(gameObject). I cannot change C.
The other qustion I want to My enemy touch B(gameObject) for the third [last] time. Than B(gameObject) can change C.
What can I do?
var thing;
function OnCollisionEnter(theCollision : Collision){ if(theCollision.gameObject.name == "enemy"){ Instantiate(thing,transform.position,transform.rotation); Destroy(gameObject);
} else if(theCollision.gameObject.name ==
"PC"){ Debug.Log("Nothing"); } }