Rotate around a sprite billboard

Hi,

I have this sprite sheet and wants to display it on billboard sprite.
I know how to set the uvs from a frame index, to display that particular frame onto my quad mesh.

Now I would like to display the right frame according to the current camera position/rotation relative to the sprite’s own position/rotation.
Since it’s a billboard display I use an invisible gameObject to store the world sprite current rotation.

So, how to find the right frameIndex ?
Also, maybe my sprite sheet frame ordering is not the best, if any is better, please tell me :wink:
Here I have a 8x5 sheet, but I would like a generic function working on any frame count.

I’m new to Unity, so I’ve certainly missed many things.

Thanks for your help

Any reason why you wouldn’t just do that as a 3D object, and save yourself a lot of bother (not to mention memory resources)?

–Eric

I’m aiming a specific rendering style

so ? no idea ?

I’m thinking of assigning a corresponding direction vector for each frame, then by searching wich one has the less angular difference with the camera current forward vector, I could find wich frame to display.

How could I do this without computing the dot product between the camera direction and all the frames directions for each update ?

Any idea of what would be the quickest way of doing it with Unity ?

Which is this exactly? If it’s just a box, you could write a script that snaps it into these specific rotations.

IIRC unity draws 3D objects faster then 2D.

You could use a two-stage process to eliminate some of the candidates from the search. For example, you could get the dot product of the character’s forward vector with the world’s upward direction to determine whether he is basically looking up, forward or down. If you’ve established he’s looking upward, for example, you only need to search through the upward-facing images. However, it’s worth noting that the dot product is pretty cheap in CPU time, so the overhead won’t be that great even if you search through a lot of vectors each frame.