summaryrefslogtreecommitdiff
path: root/Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-23 10:10:23 +0800
committerchai <215380520@qq.com>2024-05-23 10:10:23 +0800
commit81330a6b68d307937c262368a42a3fa4e9ad4207 (patch)
tree0616a08be385794e062fb616df4ffb503631ee08 /Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs
parent8722a9920c1f6119bf6e769cba270e63097f8e25 (diff)
+ NavMeshTest
Diffstat (limited to 'Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs')
-rw-r--r--Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs b/Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs
new file mode 100644
index 0000000..d6534c9
--- /dev/null
+++ b/Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs
@@ -0,0 +1,27 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.AI;
+
+[RequireComponent(typeof(NavMeshLink))]
+public class UpdateNavMeshLink : MonoBehaviour
+{
+ public Transform from;
+ public Transform to;
+
+ private NavMeshLink m_Link;
+
+ private void Awake()
+ {
+ m_Link = GetComponent<NavMeshLink>();
+ }
+
+ private void Update()
+ {
+ if (from == null || to == null)
+ return;
+ m_Link.startPoint = transform.InverseTransformPoint(from.position);
+ m_Link.endPoint = transform.InverseTransformPoint(to.position);
+ }
+
+}