How to show a 2.5d sprite correct frame, based on camera and sprite position/rotation?

alt text

Here it is some frames from an old 2.5d shooter. He does have animation frames to 8 directions. My doubt is, how to show the correct walking frame, based on gameObject rotation/direction, and the position of the camera that is facing this game object?

Are you aware of dot product in Math? You can find the angle between two vectors with dot product.

If dot of two vectors is zero, they are perpendicular.
If dot is positive, angle is less than 90. It means they look at the similar direction.
If dot is positive 1, the vectors look at the exact same direction.
If dot is negative, angle is greater than 90. It means they look at the opposite directions.
If dot is negative 1, the vectors are completely opposite.

Please see this post for more info :