2D, Seeker sprite gets rotated (becoming invisible)

I’m trying to use the A* Pathfinding Project package in a 2D game. So far I’ve got the pathfinding working, with the caveat that the game world must be rotated (X=90, Y=0, Z=0) so I can still use X/Y coordinates.

The only remaining problem is that the sprite that has the Seeker + AIPath scripts gets rotated along the X and Y axes and thus becomes invisible (as it’s just a flat sprite).

Does anyone have any tips on how to prevent X- and Y-axis rotation? I’ve tried tinkering with AIPath, replacing all the .z with .y, but that doesn’t seem to make any difference. Basically I just want the seeker to rotate around Z.

Or is there a more official way to implement A* Pathfinding in a 2D game? I’ve searched this forum and have found a bunch of folks asking but the solutions posted didn’t work for me (replacing .z with .y in AIPath, for example).

1 Like

I am having the same problem, i tried to comment Aipath.cs where it deal with rotation but it make my sprites not moving, is there a solution?

Well… A* pathfinding does not do any rotation its self (Unless your are using one of the example scripts) So what script for rotation are you using??

Here is some of the code from my movement class: hopefully it can give you some ideas
public void TurnAB(float UnitTurnSpeed, Vector3 LastPosition){
if(LastPosition == Vector3.zero){

	Vector3 LookAt = Player.position - LastPosition;
	if(LookAt == Vector3.zero){
	Quaternion LookRotation = Quaternion.LookRotation(LookAt);
	Quaternion rotation = Quaternion.Slerp(Player.rotation, LookRotation , Time.deltaTime * UnitTurnSpeed);
	Player.rotation = Quaternion.Euler(0, rotation.eulerAngles.y, 0);


yes as i said before i use Aipath.cs

and this part of the code seems to deal with rotation:

//** Rotates in the specified direction.
* Rotates around the Y-axis.
* \see turningSpeed
protected virtual void RotateTowards (Vector3 dir) {
Quaternion rot = tr.rotation;
Quaternion toTarget = Quaternion.LookRotation (dir);

	rot = Quaternion.Slerp (rot,toTarget,turningSpeed*Time.fixedDeltaTime);
	Vector3 euler = rot.eulerAngles;
	euler.z = 0;
	euler.x = 0;
	rot = Quaternion.Euler (euler);
	tr.rotation = rot;

but if i change it, it will block the gameobject and make it unable to move.
i have last version Pro from assetstore

I know it’s a very old post, but I’m having the exact same problem:

AIPath.cs rotates my sprite making it invisible when it’s moving and commenting or changing in any way the RotateTowards method just makes the seeker sprite unable to move.

Did anybody find a solution for this?

Thank you


The simplest method is to put the sprite in a child and rotate the child so that when it moves, it is rotated correctly.