Search Unity

Delete on collision detection. Deletes the collider component rather than the prefab

Discussion in 'Scripting' started by xxlilxjxx, Jul 3, 2015.

  1. xxlilxjxx

    xxlilxjxx

    Joined:
    Jul 21, 2014
    Posts:
    28
    So I want a ring to be deleted once it's been touched by the player. I noticed that the BoxCollider that I have as a component for the ring deletes. Instead of the entire ring. I want the whole ring to delete. How can I do this? Assuming from Lua, can I get the parent or something? Any other method would be great also.


    #pragma strict

    function OnTriggerEnter(col : Collider){
    if(col.gameObject.tag == "Ring"){
    print("isring");
    Destroy(col);
    }
    }
     
  2. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
    Instead of "Destroy(col)" do "Destroy(col.gameObject)"