[Solved] Is there a way to add variables in the place of Objects name in the animation action?

Heyo guys

I have a group called Dragons that includes all of my dragons objects.

First, there is an action where you click on a dragon and the buy window pops up.

Now I was wondering… Is there a way to put this variable

image

as an Object name in the animation set up panel?

Cause if I put it as the group “Dragons” it changes the animations of all the objects in the group.

Can you screen shot where you put the change animation by name action? It should be in the subevent of your screen shot.

1 Like

Normally I wanted it to be here, under the YES BUTTON action.

(Please ignore the string comparison as it’s not working for some reason.)

I also tried to put it as a sub-event under the action of my first port, or put it in the same event line of both “YES Button” and “Dragons is clicked” but it still changes the animation of all the dragons in the Group.

Okay theoretically I know that this way is wrong as I am not “choosing” a dragon at the YES DRAGON action but I have no idea how to do it otherwise. This is why I wanted to store the object name into a variable and put it in the animation panel that way.

Is each dragon created from a different object/sprite? If so, make that last event in your screen shot a “Repeat for each instance of Dragons”, and in the conditions put the WhiteWool > Dragons.Cost and another condition that does a text comparison between Dragons.ObejctName() and the variable CurrentlyBuying, making sure they are the same.

1 Like

YOU ARE A GENIOUS IT WORKS! THANK YOU!!! :smiley: :pray:

I feel like I just upgraded a part of my Gdevelop brain. I was going to ask why it worked but I kind of understood it after staring at it for a while.

Just saved me hundreds of lines of useless events.

So just co close the thread.

Is it not possible to put Variables as names in the animation action?