- Home /
 
Another collision detection issue
I know this is rather juvenile of me, but it appears everything is set up correctly. I have checked and double checked and it all looks fine.
I have an 'enemy' with a box collider and a rigidBody with isKinematic set to true, and this script attached to it:
 #pragma strict
 var stats : EnemyStats;
 
 function Start(){
     
     stats = GetComponent( EnemyStats );
     
 }
 
 function OnCollisionEnter( collided : Collision ){
     Debug.Log( "Took damage from Bullet");
     if( collided.transform.tag == "Bullet" ){
         
         var bulletData = collided.transform.GetComponent( BulletData );
         
         switch ( bulletData.gunID ){
             
             case GunType.Classic:
                 stats.hp.current -= bulletData.damage;
                 break;
         }}}
 
               The only thing that you need to pay attention to is the Debug call. It is not firing when the bullet collides with the enemy! (The bullet also has a box collider). Is there some simple mistake I am making?
Answer by Forrest_Gimp · Jan 15, 2013 at 01:59 PM
I think the colliding party gets the event, not the one it collides with. I had a similar problem with a camera entering a certain zone, and the zone-collider didn't trigger. It turned out the cameras collider (and only that) got the event.
(Check this case here: http://answers.unity3d.com/questions/283347/camera-does-not-trigger-ontriggerenter-event.html)
Funny enough, I gave both parties a simple script that shows a debug on collision, and added is$$anonymous$$inematic rigidBodies to both, and yielded absolutely no results -_- what is going on?
Got it: I just went for the trigger approach. Apparently, with collisions, one of the bodies HAS to be non-$$anonymous$$inematic. (This makes sense lol).
Your answer
 
             Follow this Question
Related Questions
Applying damage with Flamethrower-like weapon 1 Answer
How to jump on to a turret gun 2 Answers
How to ignore specific collider, non-raycast? 3 Answers
How to fix code errors? 1 Answer
Play Audio While Button is Held Down 1 Answer