system
1
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
efge
2
Destroy(gameObject) also destroys the attached script, so you should call Instantiate() before Destroy().
system
3
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");
} }