第一波绿色向右(到第一个方向),但在延长隧道后,第二波就是为什么绿色--你失去了第一条路线,直接走到第二条。(为什么那是一条迂回的路?)
对不起我的英语不好。
第一波绿色向右(到第一个方向),但在延长隧道后,第二波就是为什么绿色--你失去了第一条路线,直接走到第二条。(为什么那是一条迂回的路?)
实际上有两个问题: 1)如何修复第一个方向点2)为什么到第二个方向点如此奇怪?
这是敌人的代码,可以通过路径点进行迭代。
using System;
using UnityEngine;
using UnityEngine.AI;
[RequireComponent(typeof(NavMeshAgent))]
public class EnemyMovement : MonoBehaviour
{
[SerializeField] public Transform[] points;
[SerializeField] private int destPoint = 0;
private NavMeshAgent agent;
void Start()
{
agent = GetComponent<NavMeshAgent>();
agent.autoBraking = false;
agent.destination = points[destPoint].position;
}
void GotoNextPoint()
{
if(destPoint != points.Length)
{
agent.destination = points[destPoint].position;
}
}
void Update()
{
if(agent.remainingDistance < 0.5f)
{
destPoint++;
GotoNextPoint();
}
}
private void OnDrawGizmos()
{
Gizmos.DrawLine(gameObject.transform.position, points[destPoint].position);
}
}发布于 2019-01-24 04:04:00
事情是这样的: NavMesh制造大瓷砖(NavMeshBuildSettings.tileSize),但我无法改变它,因为我使用了别人的作品(https://github.com/Unity-Technologies/NavMeshComponents/tree/mast…)mples /Script)。因此,要更改运行时navMesh,不仅必须在网格更改代码中注册,还必须编写行(.overrideTileSize = true;)
var defaultBuildSettings = NavMesh.GetSettingsByID (0).overrideTileSize = true;之后,我能够改变瓷砖的大小,并停止了对错误路径的选择。
https://stackoverflow.com/questions/53028063
复制相似问题