Grid system is used mostly in RTS games. Your characters or buildings move on grids. You need a matrix to create a grid system
public float cell_size = 2.0f;
private float x, y, z;
void Start() {
x = 0f;
y = 0f;
z = 0f;
}
void Update () {
x = Mathf.Round(transform.position.x / cell_size) * cell_size;
y = Mathf.Round(transform.position.y / cell_size) * cell_size;
z = transform.position.z;
transform.position = new Vector3(x, y, z);
}