Saturday, November 5, 2022
HomeGame Developmentc# - The Script says class not derived from MonoBehaviour in Unity

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


It doesn’t matter what script I attempt to add, it at all times says the script doesn’t include a category from UnityEngine.MonoBehaviour. An instance script I am attempting 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;

    personal Remodel goal;
    personal NavMeshAgent agent;
    personal float timer;

    // Use this for initialization
    void OnEnable()
    {
        agent = GetComponent<NavMeshAgent>();
        timer = wanderTimer;
    }

    // Replace is known as as soon as per body
    void Replace()
    {
        timer += Time.deltaTime;

        if (timer >= wanderTimer)
        {
            Vector3 newPos = RandomNavSphere(rework.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;
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments