- Home /
The question is answered, right answer was accepted
Ammo Pickup
I need ammo pickup and the best way to do this is with Triggers. So I added this to a script:
function OnTriggerEnter () {
if(collider.gameObject.CompareTag("Musket"))
{
bulletsLeft += musketAmmoPickup;
}
}
So I made the trigger on the gun on the ground. I went over it and it didn't work.
Do you have a rigidbody on your character? (for triggers, even kinematic ones will do)
Yes. Everything, including the ammo pickup has a rigidbody. This script is on a shootPoint which is at the end of the player's musket.
Put Debug.Log("IS IT WOR$$anonymous$$ING YET?"); statements in everywhere. Then, you can track down which parts of code are working, and which parts aren't! I'm afraid that's the best help I can give you, without more information about your circumstances here.
Never$$anonymous$$d, I answered my own question, with a really complicated way I couldn't put into an answer, which ended up me deleting this line of code. Thanks anyway.
Follow this Question
Related Questions
An integer that's supposed to get incremented gets reset when a bullet hits. 0 Answers
Pickup Bullets 1 Answer
Can't click gameobject when over another trigger? 1 Answer
Picking up items with Rigidbodies 2 Answers
Why do my bullets only destroy themselves sometimes after colliding with the wall? 0 Answers