[Solved] Hotbar/inventory system

I’m trying to make a hotbar system, where there are cards that I want to move to slots, and they’ll be in an order where I can remove them.

How far have you gotten? Do you have the UI or a rough mock-up? It’s tough to tell what you need help with? The moe specific you are the more likely you are to get a quick response. We all want to help. We just need more details.


I have these slots, which I want to pass these cards into the slot, I was only able to do this in the first slot, not in the other slots. I did it using an “id” variable for each slot.

In fact, I couldn’t get the card to return

Can you post the events you’re using to try and move the objects? It’s still unclear how they’re supposed to be added. Is it automatic like a deal or a pickup from collision or something? Do you click a card? Or drag it? Are you using a tween? Do the objects move there or does it cause the slot animation to change?

You need to pick the empty slots and then pick a single slot. Conditions are like filters. You can pick the empty ones by checking for collision between the card and the slot or use a boolean object variable like isEmpty equals false.

Once the empty slots are picked. You need to pick just 1 slot or Gdevelop will pick I believe the one created the earliest.

This example uses a Boolean to check if a card has been placed and another to check if a slot isEmpty. It picks the first empty slot using the position of the first slot. In my case it’s 0,300. It then uses a tween to move it and sets the booleans to true.

Your events might need to be different based on your needs.


The system I want is for the card to automatically go to the slots when clicked. When the first slot already has a card, it goes to the next one and so on, until it reaches the last slot.

Damn, that system worked! How perfect, thank you!


Question, how do I make a looping system? Mine isn’t working

There’s a bug, from what I’ve seen, if I remove the last card and place another card, it places it at the beginning

IDKW there’s a wait on the elapsed time line. You can increase the elaspsed time or add a second elasped time with a higher test value. Do something on the 1st elapsed and reset on the second. Just make sure the 1st has a trigger once otherwise it would trigger until the next elapsed time check.

I’m assuming increasing the elapsed is all you need but I’m not positive of your intentions and I also want to help you get a better understanding of timers.

As is, the elapsed condition will continue to trigger until the timer is reset. It will then continue to add wait instructions until the timer is reset. After the timer is reset from the initial wait expiring the other waits will expire on consecutive frames until they’re all processed.

Just remember only the direct lower events and subevents get delayed. It will continue to execute right up until it hits the wait action again.

How are you removing the card? You’ll need to set the card bollean back from placed unless you’re deleting it and just the one instance variable isEmpty back to false.

(I used reverse logic on that one. It should probably start as True and be switched to false or use a different variable name like isOccupied)

Anyways, before you move or delete the card add card is in collision with slot that will pick jist that slot. You can then set the isEmpty or whatever variable name to false. As is, I’m going to gurss that you’re resting all of the instances insetead of just one.


I adapted your system in this way, without the timer and to remove the card, I just did the reverse.

1 Like

Whatever works. Go for it.

The card is never deleted, only moved to the slot. I just couldn’t optimize the code any further, because if I reuse the same conditions, it crashes

Okay, but I still have the bug when I remove the last card and place another one

Can you post a screenshot of the current events including the remove and replace?


This makes the card goes to the slot and put it back to its origin place when you click on it.


I made a few changes to your code and it’s perfect!

Now there’s no more bug when removing the last card

1 Like

Thank you very much indeed! I just have another problem involving looping

What’s the problem with looping. Please post your events and explain the issue or start a new thread.