- Home /
Question by
VidyaMaker123 · Jul 13, 2020 at 09:31 AM ·
combo
Is there something wrong with my combo script
public class comboHits : MonoBehaviour
{
public Animator anim;
public int noOfClicks = 0;
float lastClickedTime = 0;
public float maxComboDelay;
// Start is called before the first frame update
void Start()
{
anim = gameObject.GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if(Time.time - lastClickedTime > maxComboDelay)
{
noOfClicks = 0;
}
if (Input.GetKeyDown(KeyCode.Space))
{
lastClickedTime = Time.time;
noOfClicks++;
if(noOfClicks == 1)
{
anim.SetBool("Attack1",true);
}
noOfClicks = Mathf.Clamp(noOfClicks, 0, 2);
}
}
public void return1()
{
if (noOfClicks >= 2)
{
anim.SetBool("Attack2", true);
}
else
{
anim.SetBool("Attack1", false);
noOfClicks = 0;
}
}
public void return2()
{
if (noOfClicks >= 2)
{
anim.SetBool("Attack2", true);
}
else
{
anim.SetBool("Attack1", false);
noOfClicks = 0;
}
}
}
it is not working and i do not know why
Comment