Been working on this script for the after noon and I just can’t seem to get it to work so I’m reaching out to the community. I’ve basically set up a trigger on my characters weapon with an invisible collider that will (hopefully) register an attack. At the moment, nothing happens when I click the mouse button, no animation, nothing. Unity gives me a yellow error ‘Unreachable Code Detected’ for the ‘yield return new WaitForSeconds(swingRate);’ so there’s an error there. This code is part of my main controller code, I’m not gonna past 200+ lines of code but feel free to ask for more code if it’s needed. Again, no red errors so I know I’m close… Any assistance you can give me will be awesomeeeeee!
// Melee Attacking Script
IEnumerator MeleeSwing()
{
while(true)
{
if(Input.GetMouseButtonDown(0))
{
anim.SetBool("Attack", true);
meleeTrigger.SetActive(true);
yield return new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length);
meleeTrigger.SetActive(false);
break;
yield return new WaitForSeconds(swingRate);
}
else
{
yield return 0;
}
}
}