# How to generate a grid? VERY beginner question

**URL:** <https://forums.unrealengine.com/t/how-to-generate-a-grid-very-beginner-question/750376>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [January 16, 2023, 8:26am UTC](https://forums.unrealengine.com/t/how-to-generate-a-grid-very-beginner-question/750376 "2023-01-16T08:26:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricMamet](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EricMamet](https://forums.unrealengine.com/u/EricMamet)\
**Post date:** [January 16, 2023, 8:26am UTC](https://forums.unrealengine.com/t/how-to-generate-a-grid-very-beginner-question/750376/1 "2023-01-16T08:26:13Z")

</div>

I just went througha simple course on Unreal 5 and I’d like to create a simplistic game from scratch (or almost).

I would like to generate a grid that would be available at design time in blueprint.

I think I’ll create a base class with a few methods/properties, including RowNumber and ColunmNumber.  
I could drop my grid cells in BluePrint and assign the ColumnNumber and RowNumber but it feels clunky…

How could I generate my grids by simply stating how many rows and columns I want?  
Then each grid element could probably infer its RowNumber and ColumnNumber buy its location?

As you can guess, I am really beginning in this so please be patient if it sounds too stupid a question…

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [January 16, 2023, 9:06am UTC](https://forums.unrealengine.com/t/how-to-generate-a-grid-very-beginner-question/750376/2 "2023-01-16T09:06:05Z")

</div>

![Grid](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/9/3b91b80c36361d199dd614aa8f154236e884e192.gif)

Use ForLoop:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/f/d/5fd7655d45d8231a3f4c3fed96c7c791b6412c2c.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/a/c1a1a13a47b3e223aff04f1266d70323c13bfdf0.png)

I hope it’ll be helpful to you.

[My Products](https://www.unrealengine.com/marketplace/en-US/profile/Aleksandr+Sidorov)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 16, 2023, 9:27am UTC](https://forums.unrealengine.com/t/how-to-generate-a-grid-very-beginner-question/750376/3 "2023-01-16T09:27:23Z")

</div>

2D Grid Execution macro. Couple of examples:

> [@can blueprints be used to chop an image into pieces?](https://forums.unrealengine.com/t/can-blueprints-be-used-to-chop-an-image-into-pieces/104930/2):
>
> See if you can adapt the following to your needs: A material for the actors. It takes 3 scalar values - U, V and Size. UV is going to shift the coordinate and Size dictates the number of pieces. A \*PuzzlePiece \*actor that has a simple cube (with Z scaled down to make it flat), a Dynamic Material Instance is going to be fed data when the actor is spawned - the U, V and Size are variables ExposedOnSpawn The \*LevelBlueprint \*spawns PuzzlePieces. The 2D …

> [@How can I do grid based movement?](https://forums.unrealengine.com/t/how-can-i-do-grid-based-movement/407682/6):
>
> Sure, add components in the ConstructionScript: And place the object in the level.

> [@How do I get mouse clicked position on chessboard mesh](https://forums.unrealengine.com/t/how-do-i-get-mouse-clicked-position-on-chessboard-mesh/88592/5):
>
> [QUOTE=Loucsam;686801] I’m not sure I can count on each square (of the image material) being exactly the same width or height right across the board, even though by eye it appears uniform. I might have to do some pixel colour interrogation if we are close-ish to a border of 2 squares and make an intelligent guess or perhaps just deny the click if it is within say about 5% of the border. [/QUOTE] The lack of accuracy might be caused by the fact that inverse transform gives you the coordinates …
