Hello, I’m a beginner of this path finding package…studying ‘get started manual’
void Start() {
seeker = GetComponent();
charControl = GetComponent();
seeker.StartPath(transform.position, target.position, OnPathComplete);
}
void OnPathComplete(Path p) {
if (!p.error) {
path = p;
currentWaypoint = 0;
}
else
Debug.Log(p.error);
}
void Update() {
if (path == null) return;
if (currentWaypoint >= path.vectorPath.Count) return;
Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position).normalized;
dir *= speed * Time.deltaTime;
Debug.Log("dir=" + dir);
charControl.SimpleMove(dir);
if (Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]) < 0.2f) {
currentWaypoint++;
return;
}
}
/////
this script works finding the path(seeker.StartPath()…)…
but the character game object(capsule game object) doesn’t to move toward the target transform…
So I printed the ‘dir’ variable…
Strangely, it produces the only ‘y axis value’, even though it is on the x-z plane…
??
dir=(0.0, -3.6, 0.0)
dir=(0.0, -3.0, 0.0)
dir=(0.0, -3.3, 0.0)
dir=(0.0, -3.7, 0.0)
dir=(0.0, -11.2, 0.0)
dir=(0.0, -14.3, 0.0)
…
I use Unity 4.6.9 and a* path free version 3.7.4