1
我試圖創建一個流浪AI流浪AI團結C#
我使用統一標準的資產第三人正在AI
但問題是AI只移動到某一點,它不能
這些點之間巡邏
這裏是代碼?
我該如何修改它巡邏?
using System; using UnityEngine; namespace UnityStandardAssets.Characters.ThirdPerson { [RequireComponent(typeof (UnityEngine.AI.NavMeshAgent))] [RequireComponent(typeof (ThirdPersonCharacter))] public class AICharacterControl : MonoBehaviour { public UnityEngine.AI.NavMeshAgent agent { get; private set; } // the navmesh agent required for the path finding public ThirdPersonCharacter character { get; private set; } // the character we are controlling public Transform target; // target to aim for private void Start() { // get the components on the object we need (should not be null due to require component so no need to check) agent = GetComponentInChildren(); character = GetComponent(); agent.updateRotation = false; agent.updatePosition = true; } private void Update() { if (target != null) agent.SetDestination(target.position); if (agent.remainingDistance > agent.stoppingDistance) character.Move(agent.desiredVelocity, false, false); else character.Move(Vector3.zero, false, false); } public void SetTarget(Transform target) { this.target = target; } } }
非常感謝兄弟 – Arash