- Home /
How do I call sprites from spritemaps frame by frame using Mechanim? Is there another solution?
I would like to call some of my environmental animations frame by frame so that the environment tiles can be synchronized in the same animation state and cycled at irregular intervals en masse. I have written code to do this using a state machine that alternates the value of one bool from true to false with each step in the animation (eg. bool = true goes from frame one to frame two, and then waits until bool = false to go from frame two to frame three). I have used similar strategies to cycle between 3d animations (although the bools changed because of user input not time - both are code driven, so this should not matter), however, neither blend trees nor states allow me to switch between individual sprites using one bool. The animator does not appear to provide answers, but I am much less familiar with that than I am with Mechanim so there could be a solution with that tool which I am currently unaware of.
I have a "Motion" based on a Spritemap that cycles perfectly, but does not allow the behaviour I desire. Possible (hacky) solutions include: 1) I could create individual "Motions" with one frame of each animation and cycle between single frame "Motions" using my current code 2) Do the same thing with "Motions" and use blend trees (1D) and change the code to increment a float that blends between sprites
OR if anyone knows a better solution I am open to using Animator, rewriting my code, or doing Spritemaps manually to get frame by frame control
FYI: I am not displaying any individual sprite for less than five frames, but my code allows me to change the sprite any frame after that
Your answer
![](https://koobas.hobune.stream/wayback/20220613134728im_/https://answers.unity.com/themes/thub/images/avi.jpg)