Sprite frame by frame rotation


I have the following sprite. Each frame is 32x48 px. The idea is like this… when my hero is aiming at different angles, different frame is used, and below shows the sprite sheet that I have.

e.g. [frame0: angle = 0, frame5: angle = 90, frame7: angle = 180].


I have tried setting Animator.playbackTime property after calling Animator.StartPlayback().

I have also tried using an Animation component instead of Animator.

public float Test;
void Start() {
    Animation anim = GetComponent<Animation>();
    anim["hero_torso].time = Test;

None of my methods seems to work. I don’t seem to find a way to directly manipulate the frame to show.

Is there a way to achieve what I want without having to split the sprite sheet into individual frames and do everything manually?

Thanks in advance.

This is the second time today this issue has come up of wanting to set a sprite to a specific frame. I poked around some to see if I could find a solution. The few solutions I found were ugly. Assuming there are not a lot of the sprites, I suggest you them up as a Quad instead. You can use Material.SetTextureOffset() and Material.SetTextureScale() to select a specific portion of your sprite sheet. The Animating Tiled Texture Extended script in the Unity Wiki uses this methods, so you can take a look at that script. If you are going to have a lot of these characters, you can directly manipulate the uv coordinates in the mesh. For a regular layout in the sprite sheet, the code is fairly straightforward.