[Solved] Why are the objects not going into stacks?

How do I…

I’ve a few objects ‘Hex’. And 2 stacks: ‘Stack1’ and ‘Stack2’
I have 2 boxes representing 2 stacks for visualization.
However I use coordinates instead of the boxes themselves.

What is the expected result

When I drag an Hex into first box, it should get added to Stack1
When I drag a Hex into 2nd box, it should get added to Stack2

What is the actual result

The Stack2 is simply not getting updated.

Related screenshots


Hey Ramen, there are 2 validX2 in your first shown event block. However your Stack2 event is looking for the value of validX2 and validX3. Not sure this is the problem. Just noting it and waiting to hear response.

Hey @Lucky-j
Thanks a lot for your prompt reply as always!

And yes, I fixed that error. However now I see a new one!
I dont know how I missed it!

However now I see a new problem:
The objects are not getting added to stack in straight vertical line as expected.
Do you happen to be able to figure out please?
Project 1

Corrected code:

From watching the game play I’m going to suggest changing all the > in the shown events to ≥ and all the < to ≤. I’m not sure this will work but it seems to me that maybe the hex that are exactly at 800, or exactly at 992 and 1184 are not being counted.

Edit but I wait for your reply, since I am not sure this suggestion will help. Because watching again I see the last hex dropped is clearly in range. It looks like it might be the Y position instead. See how the last hex placed needs to be at validY2 which is 448 but you place it at 512 so it’s not counted. The first hex placed needs to be at 512 but it doesn’t seem to know that until after you place it. Then the second hex needs to be at 512 but you place it at 448, then the third hex you do place at 512 so we finally have a hex counted to the stack.

Hello @Lucky-j

That was a really good catch! You seem to be great at GDevelop.
I managed to fix it all thanks to you!

Hope you’ve a great weekend!

1 Like