I have sprites (or sets of sprites) that I plan on using in a 3D game. I have been trying to calculate a formula that will allow it to show the correct sub-image based on where the camera is looking and where the AI (or sprite) is looking.
e.g.
If the camera is looking at 180 Degrees and the AI is looking at 45 Degrees then the subimage shown would be 1
If the camera is looking at 0 Degrees and the AI is looking at 45 Degrees then the subimage shown would be 5
(The sprite starts at looking straight then goes anti-clockwise).
Basically if you imagine Doom that has the 2D enemy sprites, and they move in 8 directions - thats exactly the thing i am looking for, the image used is based on the ai's direction and the players *camera* direction (basically just the camera direction)
I can't really explain it more than that sorry, but hopefully i have explained it well enough that you might be able to put the pices of the puzzle together.
Edited by millzyman, 20 February 2012 - 09:40 PM.











