c# - Collision script on an object to be collided with from the player for pickup -


i'm trying write script allows player walk pack of ammo (or health) , gain doing so. i'm struggling actual collision part of no matter can't seem work. have script on ammo pack object.

void ontriggerenter(collider collision) {     if (collision.gameobject.tag == "player")      {         debug.log ("collided");     } } 

my ammo pack object has collider on (currently capsule, box final product) has "is trigger" enabled. player has capsule collider (non-trigger) , rigidbody gravity enabled , else default. tagged "player". when player walks ammo pack, there no message printed.

i've tried several solutions involve changing triggers on colliders , rigidbody kinematic settings none of them seem work. i'm using unity 5 , wondering if i'm doing wrong. appreciated.

this function never called because capitalisation wrong. capitalise first letter of function name.

void ontriggerenter(collider c) 

instead of:

void ontriggerenter(collider c) 

note: use comparetag() instead of == compare strings. both work comparetag gc friendly.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -