the way i want it to work is the following , my player has a grenadelauncher with 3/6 bullets , next to him is an item spawner with a rocket launcher with 2/2 bullets , i want the players item to go in the item spawner and the item inside the item spawner to go inside the player hand , this is the code for equiping that i currently have:
private void OnTriggerStay2D(Collider2D collision)
{
if (collision.GetComponent<ItemSpawner>() == null) { return; }
if (hasinteracted)
{
if (equippedweapon == null)
{
//EQUIP
if (collision.GetComponent<ItemSpawner>().spawneditem != null)
{
Destroy(equippedweapon);
equippedweapon = Instantiate(collision.GetComponent<ItemSpawner>().spawneditem, weaponholdpoint);
}
collision.GetComponent<ItemSpawner>().RemoveItem();
}
else
{
//SWAP
if (collision.GetComponent<ItemSpawner>().spawneditem != null)
{
auxweapon = collision.GetComponent<ItemSpawner>().spawneditem;
Destroy(equippedweapon);
equippedweapon = Instantiate(collision.GetComponent<ItemSpawner>().spawneditem, weaponholdpoint);
collision.GetComponent<ItemSpawner>().spawneditem = auxweapon;
}
}
}
}