Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.
How do I…
How do I set a sprite’s animation to a random frame?
What is the expected result
When I run the game, the frame of the sprite’s animation should be at a random value, based on the number of frames in the animation itself. I want to add more frames at a later point in time, so I do not want to use fixed values.
What is the actual result
Animation always plays through to the last frame and stops at the last frame.
I believe the first frame is really zero. So, you would use random (count-1). Also, I believe that you need to pause the animation. I don’t know if you can just pause it at the beginning or you have to pause it after each animation change.
A variable isn’t needed unless you need the number elsewhere or it helps you better understand the process. I usually breakdown complicated formulas myself instead of creating lengthy single events.