Random numbers are same for every instance

i want so that every instance will check if it is touching other item or it’s own instance but the random number is just choosing a same number for both the instance
and the random with step is not working too

Hi, I didn’t understand what you wanted to do.

I want the timer be different for every instance, it is same for all instance hence messing my code

A random wait between 0.0001 and 0.009 will be over as soon as it’s started.

A game generally runs at 60fps (so one frame every 0.016 seconds). What you’re doing is asking Gdevelop to wait less that one game frame before continuing.

so if i wait between 0.016 - 0.032 it should work,
thx :smiley:
edit:I have multiple instances of the same object and it did not work because all of then are getting the same number

Generally, that’s only 1-2 game frames. Keep in mind that’s a very short delay/pause.

but i have tested it from 1-5 seconds and both of them are going to the next slot at the same time and i want the timer to be as shortst as possible ):

Yes. It’s generally not advisable to check whether an object collides with another instance of itself. GDevelop can’t tell which instance you’re referring to in the actions.


There’s no need to repeat the conditions in the subevent. Only the Items in the first event will be used in the subevent conditions and actions.

Instead, you could try putting a “For each instance of Items” as the subevent, and use the actions you currently have.

that didn’t work ):
what i want to make is both the istance will check if the they are touching each other and if they are touching each other then they both will start a timer and whose timer with a random wait is shorter that item checks if it is still touching and if it is it will go to the next slot and the late timer instance will check too but will not collide because the first one already moved out of the way

1 Like

Add a trigger once. Here’ what works for me:

It changes both players to a random colour.

I don’t think it’s still clear as to what you’re doing. There seems to be inventory slots and items. I don’t see any timers. The wait is more like a pause. It pauses the events at that point while the rest of the events continue starting with the next event. All sub-event events get skipped until the time expires.

Instead of using a wait or timer, you can use the pick an object closest to a position or pick a random object. Otherwise, you can use a for each object event to go through the list of picked objects one at a time.

Are you dragging one of the objects? Is the other already in a slot? At this point we’re just guessing. We may be able to get your events to work but that doesn’t mean that it would solve your issue.

You can identify objects by location or by a variable or a layer. If you’re dragging an object you could move it to its own layer. There are so many different techniques.

Again, I feel we need more details.

i am trying to make an inventory system with item priority and with different sized items

You need to describe it more, put up a screen, we don’t really understand the context, that’s the main thing, then there are several ways of doing it but if we don’t understand what you want it’s going to be difficult to help you. Don’t describe your code, describe what you want to do.

i said i want an inventory system
with items as a group of collectable items like copper and silver
some items are big so they require more space in the inventory
the items don’t stack
the player has 48 inventory slots and he can make more storage in minecraft by making chests

It’s still not detailed enough.
You could make a variable Inventory = 48 and give a variable to each item for the number of slots it will take and then when it puts it in the inventory it deducts.

There are infinite ways to configure inventory.

The UI isn’t the problem. It’s the method of getting to the inventory? Tell us about your game. Is it a top down? Is the player mining or exploring? When the player discovers or digs or collides with an item, what do you want to happen? Does the item go directly to a slot or does it become the cursor or does it go to temporary holding slots. Does the player have to open the inventory every time or does it go to a holding area?

You say items don’t overlap. Does that mean there are separate spots for each piece of ore or do they combine and display the number of like items.

Inventory can be grids like a puzzle where items move around . They can be slots. They can have tabs. They can be groups of slots of different sizes or automatically adjust.

Slots can be rigid or flexible. Items can go to predefined slots or tabs. Or items can be arranged like a puzzle.

As they say “help us, help you”. Walk use through the process. If you have pictures of your game, whether detailed or a crude mockup then please share them.

the game is a 2d game, NOT top down, the player explores mines certain rocks to get certain ores and when th player is in the picking range of the item he can hover the mouse on that item and left click to pick up the item, once picked up the item will go in the inventory’s 1st slot and if another item is picked that item will go into the next slot, some items are big and requires more space, bigger items are more prioritised so they will show up in higher in the inventory, bigger items will ry to go into the 1st slot, the problem here is we can make more storage like minecraft’s chests, they don’t stack so every item requires its own space, example: i have 2 copper ore so they both will require one inventory slot each






the shuld be lie this is actually 3, 2 in the 2nd slot and 1 in the first slot

Hello, it looks complicated the way you want to do your inventory.
There’s the Flexbox extension from Arthuro555, here are 2 links that explain it:
https://wiki.gdevelop.io/gdevelop5/extensions/flex-box/

Perhaps with an object variable to define the volume of the item and take this value with Flexbox.
Otherwise by applying a different force or magnetism to each item according to the Volume object variable.

thx but sorry that is way hard for me to understand especially when there is no video about how to use it

this behaviour cannot even be turned off

There’s also the Slot System extension:
https://wiki.gdevelop.io/gdevelop5/extensions/slot-system/#actions

If you can’t manage that, you’ll have to simplify your inventory by doing away with volume sorting.