From 81330a6b68d307937c262368a42a3fa4e9ad4207 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 23 May 2024 10:10:23 +0800 Subject: + NavMeshTest --- .../Assets/Scripts/UpdateNavMeshLink.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs (limited to 'Other/NavMeshTest/Assets/Scripts/UpdateNavMeshLink.cs') 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(); + } + + private void Update() + { + if (from == null || to == null) + return; + m_Link.startPoint = transform.InverseTransformPoint(from.position); + m_Link.endPoint = transform.InverseTransformPoint(to.position); + } + +} -- cgit v1.1-26-g67d0