So i trie to make a attack combo system, here’s my script:-
using UnityEngine;
public class ComboAttackSystem : MonoBehaviour
{
int comboCounter;
public float cooldowTime = 0.1f;
float lastClicked;
float lastComboEnd;
public bool isAttacking;
[SerializeField] Weapon currentWeapon;
Animator animator;
private void Start()
{
animator = GetComponent<Animator>();
}
private void Update()
{
if( currentWeapon != null ) { Attack(currentWeapon.weaponName); }
}
void Attack(string weapon)
{
if (Input.GetButtonDown("Fire1") && Time.time - lastClicked > cooldowTime)
{
isAttacking = true;
comboCounter++;
comboCounter = Mathf.Clamp(comboCounter, 0, currentWeapon.comboLength);
for (int i = 0; i < comboCounter; i++)
{
if (i == 0)
{
if (comboCounter == 1 && animator.GetCurrentAnimatorStateInfo(1).IsTag("Movement"))
{
animator.SetBool("AttackStart", true);
animator.SetBool(weapon + "Attack" + (i + 1), true);
lastClicked = Time.time;
}
}
else
{
if (comboCounter >= (i + 1) && animator.GetCurrentAnimatorStateInfo(1).IsName(weapon + "Attack" + i))
{
animator.SetBool(weapon + "Attack" + (i + 1), true);
animator.SetBool(weapon + "Attack" + (i), true);
lastClicked = Time.time;
}
}
}
}
isAttacking = false;
for (int i = 0; i < currentWeapon.comboLength; i++)
{
if (animator.GetCurrentAnimatorStateInfo(1).normalizedTime > 0.9f && animator.GetCurrentAnimatorStateInfo(1).IsName(weapon + "Attack" + (i + 1)))
{
comboCounter = 0;
lastComboEnd = Time.time;
animator.SetBool(weapon + "Attack" + (i + 1), false);
animator.SetBool("AttackStart", false);
}
}
}
}
I get this error:
‘Player’ AnimationEvent ‘Hit’ on animation ‘2Hand-Sword-Attack7’ has no receiver! Are you missing a component?
and what my character is doing is that it play the first animation incompletely then jumps to 2nd and keeps playing that transtition until i press my mouse the 3rd time