- Home /
How to make a top-down gun pickup system for unity 2D similar to Enter the Gungeon?
I am trying to make a top down shooter where I have several guns that are separate from the player that can be picked up and dropped, but I have not found any good tutorials. I already watched the Brackeys vid, but I don't want the gun to be a part of the player sprite. I am new to Unity so any help would be appreciated, I already have a working gun that can aim at the mouse and shoot, I just don't know how to make a pick up system. thanks!
Answer by Pathojen · Aug 03, 2020 at 04:05 PM
I'm no pro at this, but this was my best attempt at a pickup system. I set up an int for each item that I could collect in my Game Manager. After that, I attached this to the item to be collected...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class collectHealthScript : MonoBehaviour
{
public GameObject CollectHealthSound;
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == ("Player"))
{
InventoryScript.AddHealthBottle();
Instantiate(CollectHealthSound, transform.position, transform.rotation);
Destroy(gameObject);
}
}
}
...and added this extra function to the game manager.
public static void AddHealthBottle()
{
healthBottles = healthBottles + 1;
}
Hope this helps.
Thanks! Not quite the inventory system i'm looking for, but I may come back to this later. @Pathojen
Your answer
Follow this Question
Related Questions
Need some help calculating Euler Angles 1 Answer
How use the rotation of a public transform as a quaternion 1 Answer
Shooting projectiles in a 2d top down shooter with multiplayer 1 Answer
character shaking when it moves 0 Answers
,Trying to flip a sprite to the left from the right side with a mouse 0 Answers