Home Game Development c# – The Script says class not derived from MonoBehaviour in Unity

c# – The Script says class not derived from MonoBehaviour in Unity

0
c# – The Script says class not derived from MonoBehaviour in Unity

[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]

LEAVE A REPLY

Please enter your comment!
Please enter your name here