Question by
Wizard-Knight · Dec 06, 2021 at 02:16 PM ·
animationanimatorcombat
Melee Combo system not working, Help!
Hi recently i just tried to create a combo system for a 2d game with animations and animator. I tried a lot to create a combo system but it's not working and i don't know why.
public Animator anim;
public float Remainingtime = 3.0f;
public int attacknum = 1;
void Start ()
{
anim = GetComponent<Animator>();
}
void Update ()
{
if (Input.GetMouseButtonDown(0))
{
if (attacknum == 1)
{
anim.SetTrigger("attack");
attacknum++;
}
else if (attacknum == 2)
{
anim.SetTrigger("atack2");
attacknum++;
}
}
if(attacknum > 2)
{
if (Remainingtime > 0)
{
if (attacknum > 2)
{
print("kj");
attacknum = 1;
Remainingtime = 3.0f;
}
Remainingtime -= Time.deltaTime;
}
else
{
if (attacknum > 2)
{
print("kj");
attacknum = 1;
Remainingtime = 3.0f;
}
}
}
}
In my opinion the problem is the timer
Any help ? Thanks.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613050230im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to play and hold on a single frame of an animator clip 1 Answer
Unable to play Death Animation. Parameters missing? 1 Answer
my animation isnt importing, and the mesh stays on the T pose 0 Answers
Animation length longer than animation curve 0 Answers
after press resume animation on the game still stopped 0 Answers