Animations not changing in grid

This is a weird very specific problem that i cant figure out. I posted a similar question on this same sort of topic and it was about looping through to create items in a grid based on a structure variable. I have since figured that out but now for some reason the items in the third column specifically dont change their animations. I already checked for misspellings so i know its not that. Please help!
Code:


Grid:

As you can see the nuke and rocket in the end of the two rows are not a nuke and rocket image. If more clarification is needed i will be happy to provide that.

I think you can simplify it to the following.
I don’t know if that will fix it. This adds the values to a text for testing.

Oh how do i implement this with all the code because i need that other functionality as well, this just seems as if it has testing code and nothing else?

I don’t understand the use of all of the > and <
I don’t think they’re needed unless I’m missing something.

IMO, Row should be mod(i,3)+1 and col should be trunc(i/3)+1

1 Like

here is the updated code:


and the result
image
i dont particularly know what went wrong here?

I think col and row are reversed and it’s incrementing i before instead of after col and row are calculated.

image

i starts at 0
0 - col 1 , row 1
1 - col 2 , row 1
2 - col 3 , row 1
etc…

ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh thanks ill try that


was this a correct implementation? it didnt seem like i did it right for me because it shows this

and again that one slot shows the gun when there shouldnt be a gun, i only have the gun in the inventory thing 1 time

Is the variable i still set initially to 0? The number between parenthesis starts at 2 but it’s added after i is increased. So, it’s probably 1 when row and col are calculated . It should be 0.

Are the SlotX and SlotY variables for the slot object numbered correctly? If one of them had the same value as another then they would both be picked and have the same image.

I was set to 1 and i set it to 0 but now both the cards in 3rd column are the gun
EDIT: i tested and it is something wrong with the 3rd column because everything changes to a gun in that column
another edit you can tel its something with specifically the animations because the debug text shows the correct names

I’m not that familiar with the grid behavior. I’m wondering if its columns and rows start at zero while your events are setup to start at 1,1

It might not have enough slots so it’s trying to pull data from an invalid slot.

I’m just guessing since I’m not familiar with the behavior. Save your project first and be ready to undo or reload it.

You might need to renumber the slot object variable so the SlotX and SlotY start at 0,0 and delete the +1 from the end of the lines that calculate the row and col.

i dont think this is the case because everything performs correctly with the correct slots just not in column 3

As a test, try expanding the inventory slot to 4x6 from 3x5
(if my logic is right, it will add a column 3. I’m guessing it now only has 0 to 2)

image

would i add any other box objects for this or no?

oh my days it actually worked thanks

1 Like