I am getting these errors because I am doing the courses not completely in order?
using UnityEngine;
using RPG.Movement;
using RPG.Core;
namespace RPG.Combat
{
public class Fighter : MonoBehaviour, IAction
{
[SerializeField] float weaponRange = 2f;
[SerializeField] float timeBetweenAttacks = 1f;
[SerializeField] float weaponDamage = 5f;
Transform target;
float timeSinceLastAttack = 0;
private void Update()
{
timeSinceLastAttack += Time.deltaTime;
if (target == null) return;
if (!GetIsInRange())
{
GetComponent<Mover>().MoveTo(target.position);
}
else
{
GetComponent<Mover>().Cancel();
AttackBehaviour();
}
}
private void AttackBehaviour()
{
if (timeSinceLastAttack > timeBetweenAttacks)
{
// This will trigger the Hit() event.
GetComponent<Animator>().SetTrigger("attack");
timeSinceLastAttack = 0;
}
}
// Animation Event
void Hit()
{
Health healthComponent = target.GetComponent<Health>();
healthComponent.TakeDamage(weaponDamage);
}
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()
{
}
}
}