Bug or I do wrong (ray cast)


hi
i have try to make a automatic sort inventory, the item will move to the left when the left weapon is delete, but some how the row 4 didnt work but another row work normal, and the column 12 is not working(when i delete item in column 11, the item in column 11 at the rightside must move)(the markup blue is work normal. the markup red is not working) , I dont know this is bug or i do wrong, please help me
thanks

The events are too small for me to read. Can you add a screenshot of the events by themselves?

What are you creating. Do you want the items to all move the the left? Or should they all move towards the first spot regardless of the row they’re on?


Here the event, after i delete the weapon in left the weapon in right side will move to left(same row)
Thanks for rep me Mr.Keith

1 Like

I’m not positve but it seems like you want to move all of 1 object to the left. I’m not clear about your variable or the way the slot objects are added. I played around with the concept earlier and I have 2 methods. They might need to be tweaked.

Try me: (the items can be dragged and dropped)
https://gd.games/instant-builds/db708a42-c87b-4f86-a002-477179daae4a

Source:
https://github.com/doug13579/gdevelop-slot-inventory-sort

You seem to be checking variables and I’m not sure what that’s about. I’m guessing you’re looking for specific items. IDK. My approach just looks for items and moves them all

My Slot objects were placed from left to right, and then to the next column. The order of the slots is very important because the for each object uses this order. It goes from oldest created instance to newest.

0,1,2
3,4,5
6,7,8

I have 1 scene number variable named Counter.
The Slot and Item objects have a variables named ID
The items have 3 animations.

oh, I see, I think I have idea to make it, thank you Mr.Keith

1 Like


Mr.Keith, I have little bit check in debug
(repeat for each instance of Slot:
change the variable ID of slot set to counter
change the variable counter add 1)
this make the ID of slot add 1 to infinity, which mean it dont have any limit, i have 48 slot, and each slot only should be one ID for lifetime.


this is how i do !

If you’re trying to add a grid of objects then you probably want to use repeat instead of for each object.
For each object uses existing objects. Unless you want to create a 2nd slot for each slot. Let me know if I’m reading this in a different way.

This uses 3 varaibles X, Y and Counter with each variable set to a defalut of 0.

There’s also an extension called Create multiple copies of an object.

Add this extention:

You would just need 1 action.

This automatically adds 4 variables to each object. The BatchID can be assigned a text value. So, you could have multiple sets of grids with their own BatchID. It uses CreationID instead of just ID.

image

OMG, i dont believe it, it can be easy like that, i feel so grateful, thank you Mr.Keith

1 Like