Search Unity

help!!! with collider!!!

Discussion in 'Scripting' started by cierczek91, Jul 31, 2014.

  1. cierczek91

    cierczek91

    Joined:
    Jul 31, 2014
    Posts:
    3
    Why collider it detects the bullet but knife not detect help please!
    Code (JavaScript):
    1.  
    2. private var vidaZombie:int;
    3. private var DamageBerreta:float;
    4. static var ZombieScore: int=10000;
    5. private var buy:boolean;
    6.  
    7. function  Awake () {
    8.  
    9. vidaZombie=100;
    10.  
    11. }
    12.  
    13. function Damage(){
    14.  
    15. //Berreta
    16. if(GameObject.Find("beretta")!=null){
    17. DamageBerreta=25;
    18. ZombieScore=ZombieScore+10;
    19. vidaZombie=vidaZombie-DamageBerreta;}
    20.  
    21.  
    22.  
    23.  
    24.  
    25. //Cuchillo
    26. if(GameObject.Find("Knife")!=null){
    27. DamageBerreta=150;
    28. ZombieScore=ZombieScore+10;
    29. vidaZombie=vidaZombie-DamageBerreta;}
    30.  
    31. }
    32.  
    33.  
    34. function OnCollisionEnter(zombie: Collision){
    35. //Health Zombie
    36.        if(zombie.gameObject.tag == "bullet-beretta"){
    37.            Damage();
    38.    
    39.         if (vidaZombie<=0){
    40.         ZombieScore=ZombieScore+100;
    41.         Destroy(gameObject);
    42.         }
    43.     }
    44.    
    45. }
    46.  
    47.  
    48.  
    49. function Start () {
    50.  
    51. }
    52.  
    53. function Update () {
    54.  
    55.  
    56. }
    57.  
     
  2. cierczek91

    cierczek91

    Joined:
    Jul 31, 2014
    Posts:
    3
    i have a solution my game objcet kinfe didn´t have a rigidbody component with this the colision is dedectet sorry for wasting your time ;D
     
  3. Hunter_W

    Hunter_W

    Joined:
    May 5, 2014
    Posts:
    57
    A tip: ZombieScore += 10; is a better way to update a value.
     
    cierczek91 likes this.
  4. cierczek91

    cierczek91

    Joined:
    Jul 31, 2014
    Posts:
    3
    thanks