Here is a video demonstration of my code. I am creating a melee combat system with a 4 hit combo. What is the possble reason for my animation playing twice before returning to the idle animation?
Here is my Player Combat script so far:
{
public bool meleeButtonPressed;
public bool canReceiveInput;
public PlayerMovement playerMovement;
private Animator playerAnimator1;
private int buttonClick;
public bool isCombatMode;
/// <summary>
/// This function should check when the player presses the attack button.
/// When the player presses it continuosly the plyer will cycle through different attack combo animations
/// </summary>
private void Start()
{
playerAnimator1 = GameObject.Find("Player 1").GetComponent<Animator>();
canReceiveInput = true;
}
public void CombatInputRecieved()
{
if (Input.GetKey(playerMovement.meleeButton) && canReceiveInput)
{
isCombatMode = true;
canReceiveInput = false;
meleeButtonPressed = true;
}
if (meleeButtonPressed)
{
playerAnimator1.SetBool("Combat Mode", isCombatMode);
playerAnimator1.SetTrigger("Melee Attack");
}
}
private void FixedUpdate()
{
CombatInputRecieved();
}
} ```