I’ve created an animation using 2d sprites. First, I imported my sprite sheets into my project. Then, I used the sprite editor to splice it up into a grid of frames. Finally, I drug it into the scene and Unity created the game object, an animation, and a controller.
Now, I would like to display a selected frame of the animation on a texture. The reason I want to do it this way is so that I can time the animation with an audio source. I’m using the audioSource.time value to drive the animation. Here is a snippet from my code.
//get the percent done of the audio
fltPercentDone = audioSource.time / audioSource.clip.length;
//figure out which video frame to show to stay in sync with audio
intFrame = (int)(intTotalFrames * fltPercentDone);
//set the frame on the sprite
DisplaySpriteFrame(intFrame);
I just need to know the property on sprite, controller, or animation to display a selected frame.
Thanks in advance,
Mike