Pickup weapons in 2D scroller game
I'm new to Unity and I'm learning all by myself by watching videos or reading forums. Currently I'm trying to make a 2D shooter game (side scrolling) where you must kill all enemies that aproach you (or jump over them) and get to the next level.
I want to make it so when the player is playing and finds a weapong on the ground he can pick it up and replace with his current AND drop the weapon he held down on the ground so he can come back and replace the weapon again.
This sounds very complicated to me, but all i want is when the players comes really near the weapon thet lays on the ground and press a key (E) he replaces it with his current.
I couldn't find any help on the Internet, so I decided to ask this nice community for help! I can give you the scripts if needed.
Answer by RicochetShooter · Sep 10, 2015 at 10:33 PM
You can have a Box Collider 2D on the weapon and make it a trigger. On the player script add the OnTriggerEnter2D method and make sure you have a Rigidbody 2D on your player so the TriggerEnter method gets called. Also add OnTriggerExit2D so you detect when leaving the Box collider.
Your answer
![](https://koobas.hobune.stream/wayback/20220612033254im_/https://answers.unity.com/themes/thub/images/avi.jpg)