提取RVO 寻路

This commit is contained in:
PC-20230316NUNE\Administrator
2024-02-05 18:56:55 +08:00
parent 04043cc6fc
commit 16d943ab6b
208 changed files with 42246 additions and 37182 deletions

View File

@@ -28,18 +28,18 @@ namespace Pathfinding {
// This is enough in theory, but this script will also update the destination every
// frame as the destination is used for debugging and may be used for other things by other
// scripts as well. So it makes sense that it is up to date every frame.
if (ai != null) ai.onSearchPath += OnUpdate;
if (ai != null) ai.onSearchPath += OnUpdatePos;
}
void OnDisable () {
if (ai != null) ai.onSearchPath -= OnUpdate;
if (ai != null) ai.onSearchPath -= OnUpdatePos;
}
/// <summary>Updates the AI's destination every frame</summary>
public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input)
{
base.OnSyncUpdate(dt, frame, input);
this.OnUpdate();
this.OnUpdatePos();
}
public void SetTarget(Vector3 pos)
@@ -47,7 +47,7 @@ namespace Pathfinding {
this.pos = pos;
}
public void OnUpdate()
public void OnUpdatePos()
{
if (ai != null) ai.destination = pos;
}

View File

@@ -41,7 +41,9 @@ namespace Pathfinding {
}
/// <summary>Update is called once per frame</summary>
void Update () {
public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input)
{
base.OnSyncUpdate(dt, frame, input);
if (targets.Length == 0) return;
// Note: using reachedEndOfPath and pathPending instead of reachedDestination here because