- Home /
3D Combo system?
I looked up few scripts before asking his question but I coludn't do it. I can't even play the first animation. Any help would be appreciated.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class combo : MonoBehaviour {
Animator animator;//You may not need an animator, but if so declare it here
int noOfClicks; //Determines Which Animation Will Play
bool canClick; //Locks ability to click during animation event
void Start()
{
//Initialize appropriate components
animator = GetComponent<Animator>();
noOfClicks = 0;
canClick = true;
}
void Update()
{
if (Input.GetMouseButtonDown(0)) { ComboStarter(); }
}
void ComboStarter()
{
if (canClick)
{
noOfClicks++;
}
if (noOfClicks == 1)
{
animator.SetInteger("condition", 30);
}
}
public void ComboCheck()
{
canClick = false;
if (animator.GetCurrentAnimatorStateInfo(0).IsName("Attack1") && noOfClicks == 1)
{//If the first animation is still playing and only 1 click has happened, return to idle
animator.SetInteger("animation", 0);
canClick = true;
noOfClicks = 0;
}
if (animator.GetCurrentAnimatorStateInfo(0).IsName("Attack1") && noOfClicks >= 2)
{//If the first animation is still playing and at least 2 clicks have happened, continue the combo
animator.SetInteger("condition", 31);
canClick = true;
}
if (animator.GetCurrentAnimatorStateInfo(0).IsName("Attack2") && noOfClicks == 2)
{ //If the second animation is still playing and only 2 clicks have happened, return to idle
animator.SetInteger("condition", 0);
canClick = true;
noOfClicks = 0;
}
if (animator.GetCurrentAnimatorStateInfo(0).IsName("Attack2") && noOfClicks >= 3)
{ //If the second animation is still playing and at least 3 clicks have happened, continue the combo
animator.SetInteger("condition", 32);
canClick = true;
}
if (animator.GetCurrentAnimatorStateInfo(0).IsName("Attack3"))
{ //Since this is the third and last animation, return to idle
animator.SetInteger("condition", 0);
canClick = true;
noOfClicks = 0;
}
}
}
Comment
i use this script.. this scripts i found on youtube. andd it work for me... you need setup animation event corretly
Answer by mehedihasanp78 · Nov 02, 2020 at 07:27 AM
You need to add " ComboCheck() " in every attack animation event. such as...
screenshot-2.png
(55.0 kB)