Hi so I am trying to make it so when you hit with your left hand, the next time you hit will be with your right hand and vice versa. Currently, when you hit with your left hand the next time you hit will be with your right hand which is good, however it just stops working after that.
bool canHit = true;
bool nextArm = true;
public GameObject LeftArm;
public GameObject RightArm;
IEnumerator hitting()
{
yield return new WaitForSeconds(1);
canHit = true;
}
IEnumerator waitForArm()
{
yield return new WaitForSeconds(2);
nextArm = true;
}
if (Input.GetKeyDown(KeyCode.Mouse0) && canHit)
{
canHit = false;
if (nextArm == true)
{
LeftArm.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 5);
nextArm = false;
StartCoroutine(hitting());
}
else
RightArm.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 5);
StartCoroutine(waitForArm());
}
}