Gdevelop is not easy

I’m trying to make a game without writing code. but even the simplest variable doesn’t work.
if the variable value is 1, switch to the first animation when the object is clicked.
if the variable value is 2, switch to the second animation when the object is clicked.

or

when the object is clicked;
if the object is from the first animation, switch to the second animation
If the object is in the second animation, switch to the first animation.

I’ve been dealing with it for two days. It is not possible to play like this.

Because every event is evaluated every frame, right now you’re saying “Object is clicked > Switch to 1 > Okay, 1 is switched, now switch to 2 > Okay, 2 is switched, now switch to 1” and repeating infinitely. To avoid a recursive loop, basically nothing happens.

To do something like this, you’ll need to learn about using and implement Toggleable states. How to toggle states using Variables [GDevelop wiki]

1 Like

Aside from Silver-Streak’s suggestion, you already got a solution for your problem from cat

There is also a very clean example that demonstrates how you can change animations with the same action:

And yes, it is all not very easy, but you can do it.

so much i could do. I’m stuck again. i want change safe animatioın. .safe has 3 animation. 1. locked, 2.opened with key. 3. oepened without key. need last click to safe, safe change 3. animation, create a key in inventory area.

1 Like