Hello, i trying to do a combo system like DmC or a hack n slash game but i need help to improve.
i want to press 3 times punch1(Z) and push 2 times Z and 1 time X to do another atack.
basically I ask help to improve the system or create a better.
using UnityEngine;
using System.Collections;
public class ComboSystem : MonoBehaviour {
private int point = 1;
private int point2 = 1;
private int totalCombo = 4;
private float timer = 0;
private float timer2 = 0;
public Animator anim;
void Start () {
}
void Update () {
Puntos ();
tiempoentrecombos ();
combo ();
print (point2);
}
void Puntos(){
//anim.SetBool ("Atacando", false);
//if (point <= totalCombo) {
if (Input.GetKeyDown (KeyCode.Z)) {
//anim.SetBool ("Atacando", true);
timer = 1;
point += 1;
}
if (Input.GetKeyDown (KeyCode.C)) {
timer2 = 1;
point2 += 1;
}
//} else {
//point = 1;
/*anim.SetBool ("hit1", false);
anim.SetBool ("hit2", false);
anim.SetBool ("hit3", false);
anim.SetBool ("hit4", false);*/
//}
}
void tiempoentrecombos(){
if (timer > 0) {
timer -= Time.deltaTime;
}
if (timer2 > 0) {
timer2 -= Time.deltaTime;
}
if (timer <= 0) {
point = 1;
}
if (timer2 <= 0) {
point2 = 1;
}
if(point == 1 || point2 == 1){
anim.SetBool ("hit1", false);
anim.SetBool ("hit2", false);
anim.SetBool ("hit3", false);
anim.SetBool ("hit4", false);
anim.SetBool ("hit5", false);
}
}
void combo(){
if (point == 1) {
//print ("1");
}
if (point == 2 && !anim.GetCurrentAnimatorStateInfo(0).IsName("Espada")) {
//print ("2");
anim.SetBool ("hit1", true);
}
if (point == 3) {
//print ("3");
anim.SetBool ("hit2", true);
}
if (point == 4) {
anim.SetBool ("hit3", true);
}
if (point == 3 && point2 == 2) {
anim.SetBool ("hit4", true);
}
if (point2 == 3) {
anim.SetBool ("hit5", true);
}
}
}
PD: is a good choice do with arrays?