提取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

@@ -1,9 +1,10 @@
using Game.Plugins.App.Sync;
using UnityEngine;
namespace Pathfinding.Examples {
/// <summary>Example script used in the example scenes</summary>
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_examples_1_1_door_controller.php")]
public class DoorController : MonoBehaviour {
public class DoorController : JNGSyncFrameDefault {
private bool open = false;
public int opentag = 1;
@@ -13,7 +14,9 @@ namespace Pathfinding.Examples {
Bounds bounds;
public void Start () {
public override void OnSyncStart()
{
base.OnSyncStart();
// Capture the bounds of the collider while it is closed
bounds = GetComponent<Collider>().bounds;

View File

@@ -1,3 +1,4 @@
using Game.Plugins.App.Sync;
using UnityEngine;
namespace Pathfinding {
@@ -19,10 +20,12 @@ namespace Pathfinding {
/// </summary>
[AddComponentMenu("Pathfinding/Navmesh/RecastTileUpdate")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_recast_tile_update.php")]
public class RecastTileUpdate : MonoBehaviour {
public class RecastTileUpdate : JNGSyncFrameDefault {
public static event System.Action<Bounds> OnNeedUpdates;
void Start () {
public override void OnSyncStart()
{
base.OnSyncStart();
ScheduleUpdate();
}

View File

@@ -1,5 +1,6 @@
using UnityEngine;
using System.Collections;
using Game.Plugins.App.Sync;
using Pathfinding;
namespace Pathfinding.Examples {
@@ -9,8 +10,10 @@ namespace Pathfinding.Examples {
/// </summary>
[ExecuteInEditMode]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_snap_to_node.php")]
public class SnapToNode : MonoBehaviour {
void Update () {
public class SnapToNode : JNGSyncFrameDefault {
public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input)
{
base.OnSyncUpdate(dt, frame, input);
if (transform.hasChanged && AstarPath.active != null) {
var node = AstarPath.active.GetNearest(transform.position, NNConstraint.None).node;
if (node != null) {

View File

@@ -25,7 +25,9 @@ namespace Pathfinding {
Camera cam;
public void Start () {
public override void OnSyncStart()
{
base.OnSyncStart();
//Cache the Main Camera
cam = Camera.main;
// Slightly inefficient way of finding all AIs, but this is just an example script, so it doesn't matter much.
@@ -41,12 +43,14 @@ 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 (!onlyOnDoubleClick && cam != null) {
UpdateTargetPosition();
}
}
public void UpdateTargetPosition () {
Vector3 newPosition = Vector3.zero;
bool positionFound = false;