Sprite sheets allow for an efficient way to render 2D animations and we use a bunch of these in our environment and UI. Being able to control the animation of the sprite sheet within Blueprint or C++ gives us the ability to trigger these sprite animations in response to specific events within the game-play or player interactions.
Below is our material setup. The specific example is for a material with User Interface as the domain since that was our requirement.
The Texture node is the sprite sheet to be animated whereas the scalar parameters Rows and Columns allow the artist to specify the grid of the sprite sheet. Next is the scalar parameter Speed which controls the speed of the animation. The Phase parameter is where the fun happens and it is the one we tweak to control the animation state. A value of 0 for Phase parameter implies the first cell of the sprite sheet and a value of 1 implies the last cell.
Once the material is setup, we can control the Phase parameter in Blueprints or C++ by converting to dynamic material instance and using the Set Scalar Parameter Value node.
The number for the field Value in the right-most node above can come from any source, for example, a Timeline node.