How to divide my terrain into selectable squares?

Hi.

My question is how can you divide the terrain into selectable squares where the characters are intanciados, the purpose of this is that I have to create lines or paths to attack my characters similar to the style vs Plants. Zombie, the player selects a division and this division lights up and when the player selects a character is intanciado in that division.

I have no idea how to do it, any suggestions will be helpful.

Thank you and forgive my English.

Good day @Abraham1532002 !

There are a lot of ways to do this.

In one of my projects, i did a simple mode. I did all objects/characters/everything, must be placed at a coords multiple of 10, (10, 20, 30, -10 , -20 …), this way is like creating a virual grid.

Then i calculate the position of the mouse in the world space, knowing wich position.x and pozition.z multiple of 10 is closer, using this (the same with Z coord):

float floatMousePosX = Camera.main.ScreenToWorldPoint(Input.mousePosition.x);
int gridMousePosX = 10 * Mathf.RoundToInt(floatmousePosX/10);
//Divided the float by 10 and multilyed again by 10 will give you a rounded to 10 number

This way, you recieve a gridMousePos multiple of 10, (for example (10,-20) or (-230,150). Then If want to highlight or create objects in the grid, they must have a 10x10 size with center at some of this points.

If need more help on how to do this, just ask for more using @tormentoarmagedoom . I will check this question again in few hours!

If this helped you just a little, Upvote and Check the answer!

Bye :smiley: