I decided to use the same thing from Fighter since we’re already doing the same thing with it, right? It seems to work fine but just wanted to see if anyone has any thoughts. I also cached the GO in Start since I read that trying to get other game objects is better in Start than Awake
namespace RPGTutorial.Control
{
public class AIController : MonoBehaviour
{
[SerializeField] float chaseDistance = 5f;
GameObject player;
private void Start()
{
player = GameObject.FindWithTag("Player");
}
private void Update()
{
if(player == null) { return; }
if (GetIsInRange())
{
print(gameObject.name + ":" + " Must. Give. Chase.");
}
}
private bool GetIsInRange()
{
return Vector3.Distance(transform.position, player.transform.position) <= chaseDistance;
}
}
}