x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

add to array is not working with structures

I am trying to create an inventory system, been having a lot of struggles but finally got something structured but when testing my inventory system is not containing the item I am trying to add. For testing purposes I am just adding an item when pressing left shift. in the debug I can see all the variables going through the game play flow correctly however as soon as it enters the 'add' node for an array it doesn't update the array but also don't get any error messages.

if you are wondering, Inventory is an actor component, inventory slot is a structure with Item and quantity variables. Item is an Actor and ItemStick is a child actor of Item

When debugging, shows all variables are ok however after finishing all the default values on the side are the same.

alt text alt text

Product Version: UE 4.15
Tags:
more ▼

asked Apr 26 '17 at 06:16 AM in Blueprint Scripting

avatar image

statphantom
6 1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

1) In first pic I see, that you got 10 slots by default. Add node is used to add new slots so if you in construction script our begin play making 10 empty slots is better to set the items value by using set array element and not create new slots xD.

2) Let's talk about structure. Can you post a pic with the item definition type and the code when you call add item in the slot

more ▼

answered Apr 26 '17 at 07:36 AM

avatar image

MK Studio
636 16 7 31

avatar image statphantom Apr 26 '17 at 08:00 AM

hey, yes I have 10 by default for testing purposes and also tried changing the data of them, no change either, this is my structure 'inventory slot'

alt text

And here is my add item function (you can tell by the first screenshot that the correct information is being passed, the quantity says value = 1 which is correct).

alt text

avatar image MK Studio Apr 26 '17 at 08:16 AM

alt text Here you calling function called Add Item alt text Here you looking on an other function called Add to First Empty

Try to check code in the right function before think that something is wrong xD

a1.jpg (96.7 kB)
a2.jpg (168.1 kB)
avatar image statphantom Apr 27 '17 at 12:18 AM

that's because there are a few checks that the data gets passed through such as checking if it is stackable, then checking if inventory already contains the item etc, and if it doesn't THEN it will add to the end of the list, I didn't want to take 5-6 screenshots showing the full flow of the code that's why my second screenshot was the debug showing that the data DOES make it into that function correctly, so this is the right function, data gets called there, but doesn't get added.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question