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"

Inventory Grid Widgets with Items that span more than one space

Hi,

I am trying to do an inventory grid system that allows me to represent items within more than one grid square, i.e. it could occupy multiple grid squares. At the moment I have a simple system with one widget that represents each inventory slot (it has a variable for a texture) and then a widget for the inventory as a whole that basically creates a load of the slot widgets and then uses the players array of items (structs with parameters for name and the inventory texture etc). However, this approach only lets me have each item as a single grid square, as the items texture is essentially set as the image in the grid square.

I am trying to setup a grid for the inventory (lets say 8*4) and then each item could be a different size (1*2 or 2*2) and then these are represented within the grid.

Obviously the grid itself needs to be a matrix of some kind, and I figured that in the struct for the item I would store int values for width and height and also an array of int's to store which slots it occupies in the inventory grid.

However, I am a bit lost in terms of how to represent the inventory within the actual widgets, because the individual slots with an item texture wont work.

Any help/advice would be greatly appreciated.

Product Version: UE 4.12
Tags:
more ▼

asked Jul 03 '16 at 10:38 AM in Blueprint Scripting

avatar image

johnparkes
22 12 10 14

avatar image samsimsom Oct 05 '18 at 12:19 PM

Hello @johnparkes Are you solved this situation?

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I'd imagine you could have bigger items occupy more inventory slots, even in a single slot inventory.

For example, a 2x2 hat could occupy 4 single slots in your array inventory system. The default texture size for this 2x2 hat would then also be 2x2, taking 4 spaces but representing one item.

more ▼

answered Jul 03 '16 at 10:02 PM

avatar image

Mookaroni
569 21 9 35

avatar image johnparkes Jul 04 '16 at 04:13 PM

I am a bit lost as to how could I get the texture to spread over more than one inventory slot though, as that approach would presumably have the texture duplicated 4 times rather than being one texture over all 4 slots. At the moment each slot is simply a button and an image, the texture for that image is set by the item it is due to represent, so it simply takes the whole texture. I am not sure how I could get it to only take a proportion of it. I had presumed that i needed another layer of abstraction?

avatar image Mookaroni Jul 04 '16 at 10:46 PM

In that case, I think you need to change your method of representing your items. It sounds like a 1x1 item works fine for your current set up, but you want bigger items to also be available.

So if you want to start using, say, a 2x2 item you're going to have to make it so that your inventory knows its working with a 2x2 item, and not a 1x1. In which case the inventory shouldn't display a texture in each of the 1x1 spaces, but rather make sure, by a method you make, that its taking up 4 connected spaces. After that is checked, then you display the texture over all four of those spaces.

In essence, you need:

  1. A layer of variables that checks what kind of item you're working
    with(Is it 1x1? Is it 2x2? ect).

  2. Then another layer to determine where you'll be placing it in your inventory (Placing a 2x2 item in the top left of a 4x4).

  3. And a layer to render the item's texture over of that 'chunk' of space(There is a 2x2 hat occupying the top left 4x4 inventory. Render a 2x2 hat on that space)

I'm sure I missed a few things, but I'd imagine this is the right direction.

avatar image johnparkes Jul 05 '16 at 09:53 AM

Thanks for the advice, I'll give it a go :-) I know roughly what I need to do, but I think it might take me some time and a few goes to get my head straight.

(comments are locked)
10|2000 characters needed characters left
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