hy, i have question : how to resetting int,
i make combo button, but when i press button again and again, it can’t to attack anymore until i stop press button and always wait for int time. so i need to make when i press button again and again, the int can resetting to 0 automaticly and faster.
this my script :
int noOfClicks = 3; //i mean this int
float lastClickedTime = 0.25f;
float maxComboDelay = 0.5f;
void Update()
{
if (Time.time - lastClickedTime > maxComboDelay)
{
noOfClicks = 0;
}
}
public void OnClick()
{
lastClickedTime = Time.time;
noOfClicks++;
if (noOfClicks == 1)
{
animatio.SetBool("Atk4", true);
}
if (noOfClicks >= 2)
{
animatio.SetBool("Atk4", true);
}
if (noOfClicks >= 3)
{
animatio.SetBool("Atk4", true);
}
if (noOfClicks >= 4)
{
animatio.SetBool("Atk4", true);
}
noOfClicks = Mathf.Clamp (noOfClicks, 0, 4);
}
//So how i can to stop int automaticly when i press fourtime, i need int back to 0 automaticly, more fater and ready when i press button again.