[ad_1]
No matter what script I attempt to add, it all the time says the script doesn’t comprise a category from UnityEngine.MonoBehaviour. An instance script I’m making an attempt to make use of is that this:
utilizing UnityEngine;
utilizing UnityEngine.AI;
utilizing System.Collections;
public class Wander : MonoBehaviour
{
public float wanderRadius;
public float wanderTimer;
non-public Transform goal;
non-public NavMeshAgent agent;
non-public float timer;
// Use this for initialization
void OnEnable()
{
agent = GetComponent<NavMeshAgent>();
timer = wanderTimer;
}
// Update is known as as soon as per body
void Update()
{
timer += Time.deltaTime;
if (timer >= wanderTimer)
{
Vector3 newPos = RandomNavSphere(remodel.place, wanderRadius, -1);
agent.SetDestination(newPos);
timer = 0;
}
}
public static Vector3 RandomNavSphere(Vector3 origin, float dist, int layermask)
{
Vector3 randDirection = Random.insideUnitSphere * dist;
randDirection += origin;
NavMeshHit navHit;
NavMesh.SamplePosition(randDirection, out navHit, dist, layermask);
return navHit.place;
}
}
[ad_2]