Download

[HUD] Multi slot (diablo-like) inventory

Hi community!

I’ve been looking for some information about multi slot inventory system, but there is only some posts with one object - one slot system. The problem is if object have more than 1 inventory slot you need to check somehow what slots he is occupying and store some occupied slots varibles for every objects.
If someone have ideas how to implement this system within Canvas (im designer and c++ for Slate is hard to learn in short time) feel free to write down your suggestions =)

i already have some concepts:

lets say my inventory have 60 slots - 10 width, 6 height

  1. 1 array of 60xBools -** inv Slots** to store what slots occupied
  2. my item (Axe) is occupying 6 slots - 2 width, 3 height
    • Axe will have some variable that stores its width and height to deliver throught BP interface in HUD , Vector2D for example - (2,3)
  3. next i need 2 more arrays of bools that store inventory width and height -** inv X** and inv Y
    -These arrays needed because unreal dont have 2d arrays, so ill use 2 fuctions to convert my data between** inv Slots** and** inv Y , inv Y**
  4. last one i need array of bools to store what slots Axe occuping - item 1

Now the pipeline (not sure that this is the right definition)
event:item pickup
||
/
get first empty slot in **inv Slots ** - (2)
||
/
Function convert Inv Slots to inv X - (2) and inv Y - (1)
||
/
write new bools to inv X - (2,3) and invY - (1,2,3) <-----vector2d (2,3) ----- event from BP interface get item variables (vector2D)
||
/
Function convert inv X - (2,3) and inv Y - (1,2,3) to Item 1 (2,3,12,13,22,33)
||
/
Write Item 1 bools (2,3,12,13,22,33) to Inv Slots

So for further interactions i can add events for hit boxes (slots) that will check if clicked hit box (and slot) is contained in Item 1 and rewrite bools in **Inv Slots ** if item is moved in inventory

Now the problems :slight_smile: :

  • 60x hit boxes, that i need to draw, its can be performed througt function,but its still a lot of work
  • HUGE switch on name for event hit box clicked 60x pins,
  • Item 1 is just 1 array to store 1 item, so if ill have max possible items with 1 slot its 60xArrays, and i need some function that loop among them to find empty
    array and write my just picked up item bools

And its only pick up and place item in invemtory. Move item in inventory and check if its trying to place in occupied slot is hard to implement.

P.S. Sorry for bad English, im using traslator :o

My work is actually “one object one slot”

when my finish my basic system i will add features like number of slots, themes, etc

like i say, its “one slot for each object”, and size going to be a variable, a apple (size 1) a gun (size 2) and the backpack going to have a size limit of example 30.
And weight limit.

but i perhaps change that in the future for object in multiple slots.

i think ins’t a easy job for beginner but can be done, i will try that too in the future :>

not hard if its “size 1”

after doing my basic inventory, my first question/problem for a inventory of this type, i think going to be how to get the overlaping slots for a size of more than 1 slots via blueprint.

but i have some ideas for trick that behavior

yes, but im talking about multi slot item (size 2, size 3 etc)
your system with size is good for storing items within arrays, thinking about how its can be done in hud makes my head explode :slight_smile:
Ill track your thread,so if you got some ideas about multislot items ill check them as soon as possible. And maybe if ill look at your blueprints in current working inventory (latest video on Youtube) ill have some ideas how to implement multi slot in your system.

you don’t need a array of bools, with the array of objects its enough

with objects of more than one, work the same, arrays and that all stuff, the only differs:

Basic:

Example Size (2x1)

Size Var in the Object saying its 2x1
Sprite 2x1

if we have a inventory of 2x4 slots like my system, and you drop a 1x2 object in the slot 1-2 you now
you must check the slot 2-2 if its free, and if free you have drop the object in 1-2, and then you must mark
1-2 and 2-2 as used. but really the object are in one slots.

I think its can’t be hard to do. basicallly in the SAME as my system but i must do the check and take in account 2 things more. That all… i think :rolleyes:

after my first month playing in “programming” in game engine one important thing i learn its i must be tricky

when im trying to be tricky i got dozens of blueprint nodes and all pins looks like spider web ))
got new idea based on your “size” item param, if this will work ill post example

i known, i got that problem too, then for each step or feature i add, i rethink how can do that better and more clear before jump to next feature. if you do all without clean and do better job then the proyect going to be huge and confused, and a nighmare for debug or add things. Or for do the last clean when finish.

lots of times i do something with dozens of nodes and when finish that part, i look again i think how can i sumarize and keep simple that stuff, and realize that I can summarize in few nodes, using fuctions, adding a var, loops or rethinking the logic.

I remove few times 2 hours of blueprint nodes build for sumarize in a 10 minutes… that happening more on begin than now.

When you finish a feature you known better what do you want, what do you need, how do… etc, and rewrite that, not only help that feature, its help for next part because you’re learning how to do things in a more easy way.

At least for me… a beginner.

I begin today, the equip part, i have the hud only, now its time for attach some clothes and guns to my character :slight_smile:

https://www.youtube.com/watch?v=o5F6_h7CrMs

as i understand you use scene capture 2d in pawn blueprint to render it on texture in your hud? and if your pawn move while char equip tab open you will see hes moving?
i planned to use the same system but scene capture will grab my character pawn clone placed somewhere under scene, cloned pawn will not recieve input. There is only one problem - if you equip something you need to copy that object and attach to my cloned pawn.
The benefits of such trick is :

  • you can play some animations on your cloned pawn,as example something to show what injuries player has, pawn holding hand near stomach if he want to eat etc.
  • you can place your cloned pawn in small room and change it depending on what happening now in real world
  • you can rotate scene capture (or cloned pawn) to see your pawn from different side, if you do this in real world and your pawn standing near wall i think you will see wall from inside, or even black screen

yes scene2d,

i disable all character movements when open the inventory. But yes if not he is moving in the scene2d

Anyway…my character have strange “motion blur” i discovery today the causer its the scenecapture, inclusive if i disable “auto activate”

Looking really good, what are your plans for this? I would love to implement this into a project that I’m working on.