123456789101112131415161718192021222324252627282930313233343536373839 |
- using UnityEngine;
- using System.Collections;
- namespace Pathfinding {
-
-
-
-
-
-
-
-
-
- [UniqueComponent(tag = "ai.destination")]
- [HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_a_i_destination_setter.php")]
- public class AIDestinationSetter : VersionedMonoBehaviour {
-
- public Transform target;
- IAstarAI ai;
- void OnEnable () {
- ai = GetComponent<IAstarAI>();
-
-
-
-
- if (ai != null) ai.onSearchPath += Update;
- }
- void OnDisable () {
- if (ai != null) ai.onSearchPath -= Update;
- }
-
- void Update () {
- if (target != null && ai != null) ai.destination = target.position;
- }
- }
- }
|