路径测试

This commit is contained in:
杨号敬 2024-12-16 11:58:13 +08:00
parent ce28192126
commit 144727feb3
2 changed files with 30 additions and 14 deletions

View File

@ -22,14 +22,29 @@ public class TaskPanel : Base
public float hidePositionX = 125f;
public float showPositionX = -198f;
public List<int> taskIDs = new List<int>();
private List<TaskItem> taskItems = new List<TaskItem>(); // 当前显示的任务列表
void Start()
{
instance = this;
hideBtn.onClick.AddListener(OnClickHideButton);
InitList();
//InitTask(taskIDs);
}
public void InitList()
{
foreach (Task_ task in JSONReader.TaskDictionary.Values)
{
if (int.TryParse(task.ID, out int taskId))
{
// 转换成功,添加到 taskIDs 列表
taskIDs.Add(taskId);
}
}
}
// 将任务栏收起或显示
public void OnClickHideButton()
{

View File

@ -86,21 +86,22 @@ public class RecuseNpc : MonoBehaviour
//添加npc的目的地到list中
public void SetNpcDes(Vector3 tar)
{
Debug.Log(tar);
Debug.Log(tar+"目标路径点");
target.position = tar;
Debug.Log(target);
NavMeshHit hit;
if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas))
{
Debug.LogError($"目标点 {target} 不在导航网格上");
}
else
{
tar = hit.position; // 将目标点调整到最近的导航网格位置
}
Debug.Log("进入奔跑++++++=");
targetPoints.Add(tar);
//target.position = tar;
//Debug.Log(target);
//NavMeshHit hit;
//if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas))
//{
// Debug.LogError($"目标点 {target} 不在导航网格上");
//}
//else
//{
// tar = hit.position; // 将目标点调整到最近的导航网格位置
//}
//Debug.Log("进入奔跑++++++=");
//targetPoints.Add(tar);
navMeshAgent.SetDestination(tar);
}