I have went through this lesson multiple times, and am unable to catch what I am doing wrong. The animation auto plays and doesn’t work with the left mouse button that I set as the trigger. How do I fix this?
Things I have done:
- Set Binding to Left Button Mouse
- Unchecked Has Exit Time and 0 Duration for three transitions
- Added Conditions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sword : MonoBehaviour
{
private PlayerControls playerControls;
private Animator myAnimator;
private void Awake()
{
myAnimator = GetComponent<Animator>();
playerControls = new PlayerControls();
}
private void OnEnable()
{
playerControls.Enable();
}
void Start()
{
playerControls.Combat.Attack.started += _ => Attack();
}
private void Attack()
{
//fire our sword animation
myAnimator.SetTrigger("Attack");
}
}