- Home /
The question is answered
Ammo Pick up C# Not Working?
I'm trying to make it so that when the player collides with the ammo pick up (Rocket Ammo) the code adds 5 extra rockets and destroyed the ammo pack.
However, in its current state, it only activates if I hit the pick up on the perfect angel normal just hitting its side or corner?
I have Riggedbody attached to both objects but still nothing.
Code:
void OnCollisionEnterEnter (Collision col){
if (col.gameObject.tag == "RocketAmmo") {
Rockets = Rockets + 5;
AudioSource.PlayClipAtPoint (Pickup, col.transform.position);
Destroy (col.gameObject);
}
EDIT: - FIXED -
I seem to have fixed it by changing :
void OnCollisionEnterEnter (Collision col){
to :
void OnControllerColliderHit (ControllerColliderHit other){
If you manage to solve your question, please don't add a [solved] or [fixed] selfmade "tag" to the title, Unity Answers has functionalitites specifically designed to organize questions and show their state.
Check out this video
I'm closing this now.
Follow this Question
Related Questions
How to hold objects in third person? 1 Answer
My weapon takes damage. help... 1 Answer
Trigger help! 0 Answers
Mission Objectives 1 Answer
Add Health on Pickup to Decaying Health,Make a collision with an object add health 2 Answers