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"

Dynamic inventory system

Hi. I'm trying to create a dynamic inventory system but I'm not doing something right. I've created an int array and I have for example (Gun - id 1 and Key - 2). After I collect the Key for example I add the id 2 in the first index of the array. I think I've added this right to the array ( I'm new to BPs ) The problem is when I'm opening the inventory. I don't know how to stop adding the same item into my inventory. I'm looping through the array and if I got the Key, it's added twice into my inv.

Collecting the item alt text

Geting the items into my inventory alt text

This is how it looks like. alt text I know where the error is ( I loop each time the same array and when true is adding again the key ) but I don't know how to pass the index which has already been added. Thank you!

Product Version: UE 4.21
Tags:
3.png (208.6 kB)
1.png (236.8 kB)
4.png (191.3 kB)
more ▼

asked Jan 15 '19 at 02:16 AM in Blueprint Scripting

avatar image

butavpaul
17 2 3

avatar image Tomwozere2k3 Jan 15 '19 at 12:12 PM

Hi,

Have you looked at any tutorials on YouTube? There are quite a lot on how to make inventories and I've never seen one made like how you are doing it, it seems overly complicated. I can give you steps here on how to make one if you need me to but it might involve starting over.

avatar image butavpaul Jan 15 '19 at 02:47 PM

Hi. Thank you for your reply. I've watched a tutorial and it uses slot1,slot2 and so on, but if I have 30 objects to collect it's a lot of work to add/remove/use so I'm trying with arrays. I've succedded something and I hope I can remove the item from the array after I use it. (I didn't got so far)![alt text][1]

As you can see here I succeededto loop through the array and check each index to see if it has some objects in it. The problem was that if index 0 has item 2, I couldn't set the brush to texture with the Key texture which is = id 2 so I had to create an event to check each texture according to the id. Thank you! [1]: /storage/temp/265436-inventory.png

inventory.png (380.5 kB)
avatar image Tomwozere2k3 Jan 15 '19 at 06:15 PM

I'm not sure if you're saying you got it working how you wanted or not but either way you shouldn't really be casting to your character every tick in the widget(bad for performance), there are a few ways to go about doing it, for instance you could on construct of the widget cast it once and promote it to a variable and just call the variable each time instead.

Do you actually need to update the inventory each tick though? surely when it is open new items wont add to it.

avatar image butavpaul Jan 15 '19 at 07:18 PM

Thank you! It works with ev construct. I'm new to unreal and I don't know very well the bps.

avatar image Tomwozere2k3 Jan 15 '19 at 08:13 PM

I'm glad, so everything is working with the inventory as you wanted then?

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

0 answers: sort voted first
Be the first one to answer this question
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