简体   繁体   中英

(26,15): error CS0501: 'ZombieController.GetReferences()' must declare a body because it is not marked abstract, extern, or partial (UNITY)

I've been creating AI for a zombie and out of nowhere, I get this error message. Here is the code.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
 
public class ZombieController : MonoBehaviour
{
    private NavMeshAgent agent = null;
    [SerializeField] private Transform target;
 
    private void Start()
    {
        GetReferences();
    }
 
    private void Update()
    {
        MoveToTarget();
    }
 
    private void MoveToTarget()
    {
        agent.SetDestination(target.position);
    }
 
    private void GetReferences();
}

This code is causing the issue:

private void GetReferences();

It's because you would normally define a function like this, such as how you did it for:

private void MoveToTarget()
    {
        agent.SetDestination(target.position);
    }

You would need to do this for GetReferences();

private void GetReferences()
        {
            //Type your code here
        }

Then you can call it in Update as you did using the code below.

GetReferences();

Basically, you haven't defined GetReferences(); Hope this helped! Let me know if you have any more questions. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM