A question about movement in game battle city

Hi, I use A* Pathfinding Project for my project.


How to know the direction to move the tank. I do not use rotations in project.

Hi

Then you will have to modify the movement script. I’m not sure what movement script you are using, but essentially you want to modify it to simply not rotate the character, and then choose the sprite based on the direction of movement. Something like

Vector3 velocity = ...;
if (Mathf.Abs(velocity.x) > Mathf.Abs(velocity.y)) {
     if (normalized.x > 0) // Use move right sprite
     else // Use move left sprite
} else {
     if (normalized.y > 0) // Use move up sprite
     else // Use move down sprite
}

Hi, aron

Thank you very much. Strong code. It’s working. Tank moving. My issue is setup grid A* :slight_smile: