I want to disable axe collider when e is pressed and enable it again when e is pressed again. I have the bool “axeOnHand” so If statements can be called when needed. But when i press e, both If statements are called. I think the problem is they are called in the same frame. But i don’t know how to solve this issue.
if (Input.GetKeyDown("e") && axeOnHand)
{
Debug.Log("axe released");
axe.GetComponent<BoxCollider>().enabled = !axe.GetComponent<BoxCollider>().enabled;
axeOnHand = false;
}
if (Input.GetKeyDown("e") && axeCollided && !axeOnHand)
{
axe.GetComponent<BoxCollider>().enabled = !axe.GetComponent<BoxCollider>().enabled;
axeOnHand = true;
Debug.Log("axe picked");
pickUpAxe();
}