I am trying to learn unity scripting, today I tried pathfinding using Aron Granberg’s pathfinding kit (free version).
If I set the target before playing the scene, the object successfully follows the actor, but what I wanted to do is that, when I click on GUI button, it should find the path for a Empty object which I have placed in the different part of the screen. I am not getting success this time.
Please help me to achieve the desired result.
GUI_Button.cs
using UnityEngine; using System.Collections;public class GUI_Button : MonoBehaviour { public GUIText lblMsg; public Transform exitPoint; AIPath ap; void Start () { ap = new AIPath(); lblMsg.enabled = false; } void Update () { } private void OnGUI() { if(GUI.Button(new Rect(15,15,100,50), "HELP ME")) { lblMsg.enabled = true; ap.target = exitPoint; ap.SearchPath(); } } }
You can see the full thread over here : answers.unity3d.com/questions/561025/how-to-change-pathfinding-target-on-click-of-a-but.html