Animated sprite play on button pressed

Prob a simple question… but is it possible to have a button which when pressed plays an animated sprite ?

many thanks!
Matt

most definitely yes.

1 Like

For easy to use UI buttons, check this tutorial to get started:

https://developer.playcanvas.com/en/tutorials/ui-elements-buttons/

1 Like

ok so struggling to get this working. I can get an animated sprite to work which is the plane with the yellow box in on the left. When pressing play the animated sprite plays.

The plane on the right is a button. It switches sprites out but it will not play the animated sprite just a static one?

any ideas?

thanks!

If you want an animated sprite on a UI element, unfortunately, you will have to manually change the frame on UI element

See this thread for more details: Animated sprites in UI

2 Likes

ok thank you… on a side note, the tick box ‘Loop’… under the sprite animation clip if unticked the sprite should only play once? seems to just keep looping sadly…

thanks you

You will have to adapt the script in the other thread to only loop once