# Create a grid inventory system

**URL:** <https://forums.unrealengine.com/t/create-a-grid-inventory-system/849384>\
**Category:** Blueprint\
**Tags:** inventory, unreal-engine, Widget, Blueprint, question\
**Created:** [April 5, 2023, 6:22am UTC](https://forums.unrealengine.com/t/create-a-grid-inventory-system/849384 "2023-04-05T06:22:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zapking9224](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zapking9224/32/1060813_2.png) [@Zapking9224](https://forums.unrealengine.com/u/Zapking9224)\
**Post date:** [April 5, 2023, 6:22am UTC](https://forums.unrealengine.com/t/create-a-grid-inventory-system/849384/1 "2023-04-05T06:22:53Z")

</div>

Hi,  
So I’m creating an inventory system and I want the player to have an m x n grid of slots. How would I create a widget that can create exactly m x n slots uniformly?

---

<div class="post-metadata">

**Author:** ![High500](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/high500/32/906557_2.png) [@High500](https://forums.unrealengine.com/u/High500)\
**Post date:** [April 5, 2023, 7:11am UTC](https://forums.unrealengine.com/t/create-a-grid-inventory-system/849384/2 "2023-04-05T07:11:27Z")

</div>

Hi @Zapking9224

Have a look at the uniform grid

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/5/9/459b6bdfe4a11dd9e720fd88d5b678ed6fe24aa0.jpeg "HTF do I? Use the Uniform Grid in UMG") ](https://www.youtube.com/watch?v=s8YswBiGSsg)

---

<div class="post-metadata">

**Author:** ![RudaFelker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RudaFelker](https://forums.unrealengine.com/u/RudaFelker)\
**Post date:** [April 5, 2023, 4:02pm UTC](https://forums.unrealengine.com/t/create-a-grid-inventory-system/849384/3 "2023-04-05T16:02:56Z")

</div>

Hello,

Here are 2 straightforward ways of doing it:  
https://www.youtube.com/embed/DTOpsTKnXnU?feature=oembed&wmode=opaque&list=PLVcVWC1bK3YV1y98Wa_DSv3ZzhDiQh480  
This one is extremely simple and does the job pretty well.

https://www.youtube.com/embed/LMO8MSRmbW8?feature=oembed&wmode=opaque&list=PLV98WIslM9wsH20l2UxDQJUDStPT-ImlM  
This one on the other hand is more complex but is way nicer and has replication cappabilities. Note that the second approach takes way longer to do.

---

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [April 5, 2023, 5:40pm UTC](https://forums.unrealengine.com/t/create-a-grid-inventory-system/849384/4 "2023-04-05T17:40:06Z")

</div>

You simpl add a grid Widget to your Inventory.

there, you can set Column/row of each children, when adding a new child to grid via “AddChildToGrid”.

The column is simply

```auto
col = MaxSlotWidth - (CurrentIndex % MaxSlotWidth
row = (CurrentIndex % MaxSlotWidth) + Math::Floor(CurrentIndex / MaxSlotWidth)

```

This is a pseudo code, you can simply convert to BP by having two Integer Variables:

- MaxSlotWidth = Maximum count of Columns in the Inventory
- CurrentIndex = The current Index of an Item of your Item Array f.e. the index of the foreach loop

Math::Floor is just a BP Math Node called “Floor”, used to round float values DOWN to a flat Integer.

col and row are the Inputs “Column” and “Row” of the AddChildToGrid.
