Question by
dylanleeweers · Jan 27, 2019 at 04:22 PM ·
gridgrid based gamegrids
I am very new to coding and was wondering how I would be able to turn this square grid script into a rectangle grid.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class boardManager : MonoBehaviour {
private int selectionX = -1;
private int selectiony = -1;
private void Update()
{
DrawChessBoard();
}
private void DrawChessBoard()
{
Vector3 widthLine = (Vector3.right) * 8;
Vector3 heightLine = Vector3.forward * 8;
for (int i = 0; i<= 8; i++)
{
Vector3 start = Vector3.forward * i;
Debug.DrawLine(start, start + widthLine);
for (int j = 0; j <= 8; j++)
{
start = Vector3.right * j;
Debug.DrawLine(start, start + heightLine);
}
}
}
}
Comment
$$anonymous$$aybe change the value added to i or j each loop? like for(int j=0; j
Your answer
Follow this Question
Related Questions
ProBuilder Element Snap to Grid (Unity 2020.1.2f1) 0 Answers
Progrids not working with poly shape 0 Answers
0.32 by 0.32 2D grid in Unity using Mathf.Round? 0 Answers
Is ther a way to base movement translation through the grid map of the tilemap? 1 Answer
How can I pre-generate a grid instead of generating it on each runtime? 1 Answer