Creating grid system for game like battleship

Hi! :slight_smile:
I’m tring to create a grid system with coordinates but I am little bit stuck.
I created an array grid like this

And I have no idea how can I add coordinate system to this and how can I know what is the cell that the player had clicked .

Thanks for help :slight_smile:

Add “flat” collider to your grid mesh, then you can “get hit under cursor” and round point to nearest cell

sorry for bad english

I suppose you have a GeneratorBP which spawns the tiles. If not, you should propably change your System and do so, as this makes you more flexible. You need 2 ForEach Loops for this and basic understanding of loops. I assume that you know how to set the Loops up, and if not, I can give you an example. Anyway, in the TileBP create 2 Variables and name them something like “HeightCoordinate” and “WithCoordinate”. You could also use an Array, but I think it’s easier to use 2 Variables. After you spawned the TileBP, access the Variable and give it the Value of the Index of the ForLoop.

If I missed something or I didn’t describe it properly I can make the 2 BPs. And as Plaxa said you have to call the function “get hit under cursor”, cast the Actor-output to your TileBP and access the Variables.

There is another way to achieve this, which basically does the same thing but uses a function “snap to grid” or something like this.

Thanks! It is wotking! :slight_smile: