Hi, I’m getting this error when entering the NavMesAgent code.
An object reference is required for the non-static field, method, or property ‘NavMeshAgent.SetDestination(Vector3)’
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyAI : MonoBehaviour
{
[SerializeField] Transform target;
NavMeshAgent navMeshAgent;
// Start is called before the first frame update
void Start()
{
navMeshAgent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
NavMeshAgent.SetDestination(target.position); // <-- Error on this line
}
}