- Home /
Question by
T0talfail · Jan 04, 2018 at 12:48 PM ·
inputcoroutines
So I'm trying to make a combo with multiple attacks per layer, and not sure how.
I'll post the script here, and a bit about where the issue is.
public class ComboCoro : MonoBehaviour { public GameObject target;
public string ComboLast;
public int MBCurrent;
// Use this for initialization
void Start() {
ComboLast = "0N";
}
void FixedUpdate() {
if (Input.GetMouseButtonUp(0) && ComboLast == "0N")
{
StartCoroutine("ComWin");
}
}
//combo attacks
void A1Ice()
{
EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
eh.AdjustCurrentHealth(-10);
ComboLast = "A1Ice";
}
void A2Ice()
{
EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
eh.AdjustCurrentHealth(-10);
ComboLast = "A2Ice";
}
void A2Fire()
{
EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
eh.AdjustCurrentHealth(-5);
ComboLast = "A2Fire";
}
IEnumerator ComWin()
{
if (Input.GetMouseButtonUp(0) && ComboLast == "0N")
{
A1Ice();
yield return new WaitForSecondsRealtime(1.0f);
yield return StartCoroutine(ComWin2());
}
{
A2Ice();
yield return new WaitForSecondsRealtime(1.0f);
ComboLast = "A2Ice";
Debug.Log(ComboLast);
}
{
A2Fire();
yield return new WaitForSecondsRealtime(1.0f);
ComboLast = "A2Fire";
Debug.Log(ComboLast);
}
}
IEnumerator ComWin2()
{
while (!Input.GetMouseButton(0) && ComboLast == "A1Ice")
yield return null;
}
}
I'm basically trying to create a system where based on the mouse button pressed, it performs a different attack. The only thing I can think of that would even begin to work is stack based FSM, but i don't understand them at all ): , any suggestions would be greatly appreciated <3
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612145819im_/https://answers.unity.com/themes/thub/images/avi.jpg)