Search Unity

collision/trigger problem

Discussion in 'Scripting' started by lesfundi, Jan 31, 2011.

  1. lesfundi

    lesfundi

    Joined:
    Jan 10, 2009
    Posts:
    628
    in the scene there are 2 cubes, one cube the a script on that move toward another cube and hits it.
    When the cube hits the other cube, both cubes needs to be destroyed. The script here below doesn't do job.


    Code (csharp):
    1.  
    2. function OnTriggerEnter (other : Collider) {   
    3.     if(other.gameObject.tag == "bomb"){
    4.         Destroy(other.gameObject);
    5.         Destroy(gameObject);
    6.     }
    7. }
    8.  
     
  2. handsomePATT

    handsomePATT

    Joined:
    Nov 30, 2010
    Posts:
    574
    are u using triggers
     
  3. DethRaid

    DethRaid

    Joined:
    Aug 29, 2010
    Posts:
    210
    Make sure that the Is Trigger box is checked in the colliders of each cube.
     
  4. lesfundi

    lesfundi

    Joined:
    Jan 10, 2009
    Posts:
    628
    why in both cubes?
    I did it on one cube and added to moving cube rigid box with kinematic and that did the job.