Forum begins after the advertisement:
-
::louie2 has a question for us on YouTube:
either i’ve done something wrong or the recoil code seems to overlook that if you change directions mid recoil you’ll change the way you’re facing and thus be able to switch the recoil direction. is this addressed in a later part? thanks
::I’m not well aquainted with the series, so I’m not sure if it is covered in a later part, but you can update your code so that the Flip()
function cannot run when you are attacking, like so:
void Flip()
{
// Prevent turning for 1 second after attacking.
if(timeSinceAttack < 1f) return;
if (xAxis < 0)
{
transform.localScale = new Vector2(-Mathf.Abs(transform.localScale.x), transform.localScale.y);
}
else if (xAxis > 0)
{
transform.localScale = new Vector2(Mathf.Abs(transform.localScale.x), transform.localScale.y);
}
}
You will need to replace the 1f with the amount of time you want to disable attack for.
Advertisement below: