mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提取RVO 寻路
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user