I followed along the course used just the one animation, i thought i would use 2.
So I added a transition state between the two and also added a trigger, the same as the first one.
My problem remains, although i have the same bug of the animation keep continuing it will be fixed in the next lecture , there is also a problem where when he finally does stop hitting he does another 1 hit animation out of nowhere so im confused if i set it up completely wrong or if there is a better way to do it.
And instead of setting one trigger when I press to attack i trigger both
namespace RPG.Combat
{
public class Fighter : MonoBehaviour, IAction
{
[SerializeField] float weaponRange = 2f;
Transform target;
private void Update()
{
//attacking behaviour
if (target == null) return;
if (!GetIsInRange())
{
GetComponent<Mover>().MoveTo(target.position);
}
else
{
GetComponent<Mover>().Cancel();
AttackBehaviour();
}
}
private void AttackBehaviour()
{
GetComponent<Animator>().SetTrigger("attack");
GetComponent<Animator>().SetTrigger("attackRight");
}
private bool GetIsInRange()
{
return Vector3.Distance(transform.position, target.position) < weaponRange;
}
public void Attack(CombatTarget combatTarget)
{
GetComponent<ActionScheduler>().StartAction(this);
target = combatTarget.transform;
}
public void Cancel()
{
target = null;
}
//Animation Event
void Hit()
{
}
}
}
Any help would be great. Thanks in advance