Simple combo sistem
I cannot figure out why my comboState var does not increase over 1.. Below is the code, the animations are based on the comboState in another script:
public class PlayerAttacks : MonoBehaviour { [HideInInspector] public int comboState;
private float comboReset; //timer for combo
[SerializeField]
private float startReset; //start timer for reseting the combo
// Start is called before the first frame update
void Start()
{
comboReset = startReset;
}
// Update is called once per frame
void Update()
{
ComboReset();
}
// Timer and Reset of the combo state
void ComboReset()
{
comboReset -= Time.deltaTime;
if (comboReset <= 0)
{
comboState = 0;
comboReset = 0;
}
else
comboState = comboState;
}
// Increase the comboState when hitting the Enemy
void OnTriggerEnter2D(Collider2D other)
{
Debug.Log("ComboState: " + comboState);
Debug.Log("ComboReset: " + comboReset);
if (other.tag == "Enemy")
{
comboReset = startReset;
if (comboState >= 3)
comboState = 0;
else
comboState++;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Random keys combo 2 Answers
any triple mouse click c# script? 2 Answers
Seeking recommendations on Combat System Templates 0 Answers
how can i make simple combo attack,, 0 Answers