I’m trying to switch my weapons on my character when the space bar is pressed. I had it before where it would change the prefab but my AI that followed the player then stopped. I changed it up so the player carries both weapons but the second weapon has “BaseballBat.active = false;” on the start method.
This is the code I have
void Update ()
{
if (Input.GetKeyDown ("space"))
{
if (gameObject.tag == "Pitchfork")
{
gameObject.tag = "Player";
Pitchfork.active = false;
BaseballBat.active = true;
}
if (gameObject.tag == "Player")
{
gameObject.tag = "Pitchfork";
BaseballBat.active = false;
PitchTag();
}
}
}
Once the code hits “gameObject.tag = “Player”;” it doesn’t allow for anymore. It just sits there not even changing the weapon, if I take that line of code out it switches the weapon but there’s no going back to the other one.