路径测试
This commit is contained in:
parent
ce28192126
commit
144727feb3
@ -22,14 +22,29 @@ public class TaskPanel : Base
|
|||||||
public float hidePositionX = 125f;
|
public float hidePositionX = 125f;
|
||||||
public float showPositionX = -198f;
|
public float showPositionX = -198f;
|
||||||
|
|
||||||
|
public List<int> taskIDs = new List<int>();
|
||||||
|
|
||||||
private List<TaskItem> taskItems = new List<TaskItem>(); // 当前显示的任务列表
|
private List<TaskItem> taskItems = new List<TaskItem>(); // 当前显示的任务列表
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
hideBtn.onClick.AddListener(OnClickHideButton);
|
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()
|
public void OnClickHideButton()
|
||||||
{
|
{
|
||||||
|
@ -86,21 +86,22 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
//添加npc的目的地到list中
|
//添加npc的目的地到list中
|
||||||
public void SetNpcDes(Vector3 tar)
|
public void SetNpcDes(Vector3 tar)
|
||||||
{
|
{
|
||||||
Debug.Log(tar);
|
Debug.Log(tar+"目标路径点");
|
||||||
|
|
||||||
target.position = tar;
|
//target.position = tar;
|
||||||
Debug.Log(target);
|
//Debug.Log(target);
|
||||||
NavMeshHit hit;
|
//NavMeshHit hit;
|
||||||
if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas))
|
//if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas))
|
||||||
{
|
//{
|
||||||
Debug.LogError($"目标点 {target} 不在导航网格上");
|
// Debug.LogError($"目标点 {target} 不在导航网格上");
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
tar = hit.position; // 将目标点调整到最近的导航网格位置
|
// tar = hit.position; // 将目标点调整到最近的导航网格位置
|
||||||
}
|
//}
|
||||||
Debug.Log("进入奔跑++++++=");
|
//Debug.Log("进入奔跑++++++=");
|
||||||
targetPoints.Add(tar);
|
//targetPoints.Add(tar);
|
||||||
|
navMeshAgent.SetDestination(tar);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user