所以這個問題是固定的,問題是Update中的U沒有大寫
幾周前,我和幾個朋友開始制作 FPS,我現在正試圖讓 AI 朝著玩家走去,但敵人就像一個隨機物體一樣靜止不動。
我嘗試重寫代碼,重做 NavMesh,重做玩家和敵人組件(在我作為獨立開發者的兄弟的幫助下),我遵循了統一的檔案,甚至嘗試在不同的專案中做 AI,但它只是沒有不行。
我沒有收到任何錯誤,所以我不知道我做錯了什么,現在在這個 AI 上呆了一兩天
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class PlayerNavMesh : MonoBehaviour{
private NavMeshAgent agent;
private GameObject target;
private void Start()
{
agent = GetComponent<NavMeshAgent>();
}
private void update() {
target = GameObject.FindGameObjectWithTag("Player");
if(target != null)
{
agent.destination = target.transform.position;
}
else
{
Debug.Log("No target found");
}
}
}
uj5u.com熱心網友回復:
Update()應該大寫。另外,為什么要設定target每一幀?
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/405082.html
標籤:
