I am trying to make a copy of the old game show Concentration. I have ran into an issue where when a card is clicked it changes to the front animation of the card, but does not increment the variable FlippedCount +1 although there is an action for this.
The Problem:
In the event, the action to change the card’s animation works perfectly, so I know the event is running. However, the very next action, Change scene variable FlippedCount: add 1, does not work. The variable always stays at 0.
What I Have Already Confirmed:
FlippedCount is a Scene Variable, and the name is spelled correctly in the action.
The action is set to add 1 and it is not disabled.
The action right before it in the same event works fine.
I can’t figure out why this one action is failing. Can anyone see what’s wrong?
Hello and welcome. There appears to be an unconditional event to change the variable FlippedCount to 0 at the bottom of the screenshot. Have you tried to disable this sub event to test if it causes conflict?
Thanks for the response! I have tried that and still have the same issue of the FlippedCount not increasing. I am new to GDevelop so am unsure if there is something I am missing here.
You can debug a lot of ways. One easy way if you’re new is to make a text object called debug. Drag it into the scene where you can see it. Add an action right under your action that is not working to change the text of debug add (not set to) “Test” or some message. Then run and click your card. If the text doesn’t change at all from the default text you know that action really isn’t working. If it changes then you know the action is working but something somewhere is putting the variable back to 0. This will help you narrow things down.
Since the first event, and possibly others don’t use Trigger once, the variable increases multiple times, likely far more than intended. If the condition stays active even briefly, the variable can quickly become a large number. You probably want it to increase only once, so using Trigger once is essential to prevent these rapid, repeated changes. This likely affects your other variables as well.
Looking at your code in its current state, it seems that it always jumps to the last event and resets the variable to 0. Simply removing that last event won’t solve the problem. That’s because most of your conditions are being skipped, since the variable isn’t 1 or 2, but much higher, and as a final fallback, it gets reset to 0. This explains why your logic isn’t working as expected.
How are you determining that the variable is not increasing?
No, because all of the events in the screen snip are subevents of the first event. That first event is controlled by the button release condition which has the same effect as a trigger once condition. Adding Trigger Once conditions willy-nilly is pointless.