How do I change animation of object according to the button i presss?

Hello
I am trying to change sprite animation according to the button that has been checked, but there are 2 problems
1.I know i can do manually for each button
EX) X BUTTON IS CLICKED CHANGE THE SPRITE ANIMATION TO X
but I have to add lots of buttons so i feel like there might be an efficient way
2. I have multiple sprite instance and i want to keep changing the animation of next sprite every time i check the button
hope i was able to explain

If the object name of each button matches the animation name, then you could put all the different buttons onto an object group (say named ButtonGroup), and use the follwing:

ButtonGroup definition:




Event:

image

What you said is working
But the thing is i have multiple sprite that i have to change the animation of
Ex). If i have 5 button and 3 sprites so if i press any button the 1st sprite animation should change and then if press another button it should change the 2nd sprite animation and so on

I thought it worked
but when I try to take it back to empty animation


the adding part is working
but not the subtracting one

Is this for something like a player selection screen where each icon or player or player type can only be picked once?

Instead of checking for the ID in the last event, you could either test if the animation equals the text of the unchecked button or the ID related to the button that was clicked for the object.

As is, your concept might work if the toggle buttons are unchecked in the order they were checked. Although, I think you need to change the animation and then subtract 1. Variable2 equals the most recently changed animation.

Using CurrentID instead of Variable2 would also be helpful.

Here’s how I might do it if it was a player pick screen.

My scene. The X is the test position object. So, it picks the object that’s closest to the left.

Events

For testing, I just used animations with the number 0 thru 5 which correspond to the animation name.

The ID concept would only work if the buttons were checked and unchecked in the same sequence.

I used copies of the same button, so used an object variable named “Name”

So this is the layout I have been trying to work with and I did the same as you did But it is not working Maybe because the layout is different
I am using ID at the place of name variable that you are using

It looks like it should work as long as the variable and animations match.



This is the closest I have been able to get to what I want but as you said above that the subtraction part might not work The thing is that if I Uncheck all the buttons in any order it sets the animation to empty slot as expected the way it should work But If I only uncheck few buttons then it doesn’t work and and if I try to again change the animation from empty slot it does not work