A* pathfinding for 2D top Down

So I have begun creating a 2D top down shooter and started to implement an A* AI approach. I have been reading “Unity 4.x Game AI Programming” and got their A* algorithm working correctly but the book stops once you get a Debug.DrawLine to show the path, it does not go into moving the character to each node. I was wondering if anyone could help me figure this out. I could post parts of code if anyone wants, but I think it is a very standard simple A* pathfinding algorithm. I am moving my characters right now using transform.Translate and have a method for rotating the sprite correctly. Just curious if there is a good way to go about this that I’m not aware of. I hope I’m not asking a question that has been asked a million times, I couldn’t find an answer is the only reason I’m using Unity Answers. Thanks!

Vector3 directionWeShouldGo = (targetPosition - transform.position).normalized;

transform.Translate(directionWeShouldGo * Time.deltaTime);

The direction can be established with simple a - b normalized where a and b are the target position and the current position then normalized to form a direction. Just feed that into transform.Translate and voila.


You can look down the path with Quaternion.LookRotation() or transform.LookAt(targetPosition);

Then you can simply do …

transform.Translate(Vector3.forward * Time.deltaTime);

…until you reach the destination.