Why does the cube just move a bit and then stop?

HomeForumsA* Pathfinding ProjectBeginner QuestionsWhy does the cube just move a bit and then stop?

This topic has 1 voice, contains 2 replies, and was last updated by  Ziege 23 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
Author Posts
Author Posts
January 25, 2012 at 01:13 #1340

Ziege

I just followed the tutorial and got an error: the green path line is correct, but the enmey cube only moved a bit, from (72, 3.5, 8)to (71.5, 3.08, 8.5), and it’s destination should be (9, 3.08, 16). Why is that?
The movement code is also from the tutorial(AstarAI.cs).

Help me please!

PS:
here is the screenshot:
http://wwwhomes.uni-bielefeld.de/jhe/astar.png

January 25, 2012 at 21:10 #1342

Ziege

I have tried to add rotation to the code, but it does not work. The cube circles at the start postion like crazy.

Can anyone help me?


public void FixedUpdate () {

if (path == null) {

//We have no path to move after yet

return;

}

if (currentWaypoint >= path.vectorPath.Length) {

Debug.Log ("End Of Path Reached");

return;

}

transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(path.vectorPath[currentWaypoint] - transform.position), rotationSpeed * Time.fixedDeltaTime);

Vector3 forward = transform.TransformDirection(Vector3.forward);

controller.SimpleMove(forward * speed * Time.fixedDeltaTime);

/*

//Direction to the next waypoint

Vector3 dir = (path.vectorPath[currentWaypoint]-transform.position).normalized;

controller.SimpleMove(dir * speed * Time.fixedDeltaTime);

*/

if (Vector3.Distance (transform.position,path.vectorPath[currentWaypoint]) < nextWaypointDistance) {

currentWaypoint++;

return;

}

}

January 30, 2012 at 13:07 #1385

Ziege

problem solved

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Why does the cube just move a bit and then stop?
Your information:






<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>