http://www.arongranberg.com/unity/a-pathfinding/
For A* Pathfinding Project version 2.5, I tried updating the clicker.cs so instead of following the mouse click the robot follows a fpscontroller.But sadly it doesn't work... Does anyone wanna check this out?
Code:
using UnityEngine;
using System.Collections;
public class Clicker1 : MonoBehaviour {
//An object which will be used as a marker of where the pathfinding target is currently
public Transform target;
//The Seeker to start pathfinding from when clicking
public Seeker controler;
RaycastHit hit;
public LayerMask mask;
//The object to use when placing stuff on the ground
public GameObject building;
//If true, the target will be moved every frame instead of on every click, paths will not be calculated on click
public bool continuous = false;
private GameObject newTarget;
private GameObject animatedObject;
void Start(){
animatedObject = GameObject.FindWithTag("Player");
}
// Update is called once per frame
void Update () {
target.position = animatedObject.transform.position;
if (!continuous) {
controler.StartPath (controler.transform.position,target.position);
}
}
}
Any help is appreciated. Thanks.