- Home /
Why the gameObject doesn't destroys?
I want that if I pass over the gameObject it destroys and give me the message, what I'm not doing right?
#pragma strict
function Start () {
}
var rotationSpeed : float = 100.0;
function OnTriggerEnter(col : Collider){
if(col.gameObject.tag == "Player"){
col.gameObject.SendMessage("CellPickup");
Destroy(gameObject);
}
}
function Update () {
transform.Rotate(Vector3(0,rotationSpeed * Time.deltaTime,0));
}
Thanks!
Comment
Now that you've corrected the spelling and it's obviously still not working, perhaps your player is not tagged with "Player".
Or maybe your object collider has not been marked as a trigger.
Answer by Imankit · Dec 25, 2012 at 05:16 PM
it should be...
Destroy(col.gameobject);
That will destroy what collides with his object. In this case, his player.
Okay.. probably your game object on which you are passing is not tagged as "Player"..
Your answer
![](https://koobas.hobune.stream/wayback/20220613085855im_/https://answers.unity.com/themes/thub/images/avi.jpg)