,Can you please give me the code to enable weapon pickup and also how to toggle between both weapons. I just want the second weapon to be picked up when I touch or even a code in which by pressing X to pick up the nearest weapon is also fine. Just please share me the code that would be successful. I am using Unity for the first time and don’t have any knowledge about c#. Kindly do help me.
public GameObject Weapon1;
public GameObject Weapon2;
void update()
{
if(Input.GetKeyDown(Keycode.Q)
{
Weapon1.setactive(false);
Weapon2.setactive(true);
}
if(Input.GetKeyDown(Keycode.E)
{
Weapon2.setactive(false);
Weapon1.setactive(true);
}
It wont be perfect, but it isn’t too bad for what I can do