- Home /
How to stop sprite animation on single frame?
So, I have a sprite with multiple images that I just added as a texture in my game, dragged into my scene and it automatically created an animated sprite with an animator and stuff for me.
The animation currently cycles through all the images on an endless loop, but what I'd like to do is stop it on one of the frames, and it would be cool if that could be either a frame of my choose or random.
How would I do this?
Note: If you're going to supply code, can please show the "choose frame" and "random frame" versions separately just so it doesn't confuse me.
Note 2: I did see a random example or two of potential code when I did a search, but it was like 30 lines long and too confusing for me to understand and follow, and I really don't think it should require that much code to simply stop the anim playing on a single frame (be it one of my choosing or random), so I'm hoping you can ideally give me a really simple and intuitive solution for this that only takes a few lines. I mean, ideally Unity should have something as simple as anim.Stop/anim.Pause/anim.SetFrame and anim.Speed (which you'd set to zero) and you pick what frame it stops on--but it doesn't.
Note 3: In this particular instance I'm gong to use this solution to set a bullet decal to a random image from the sprite sheet each time the player fires, in case that helps you understand better exactly what I'm looking for.
Your answer
Follow this Question
Related Questions
Stop Whole game except one one object 1 Answer
how to display a single frame of a sprite animation 1 Answer
Playing animation frame by frame by procedural controller 5 Answers
How can I access a spritesheet's current frame within a script? 0 Answers
Playing animation frame by frame depending on speed (time) 1 Answer