very, very new to scripting in general, took 3 weeks of constant study to feel like i had a handle on it, turns out it wasnt long enough. can anyone tell me what im doing wrong? i understand the way my stuff is written is probably horrendous but like i said im new, and this is my first.
wanted a big block made of smaller blocks, it was a test. every time i run the code unity freezes, there is no compiling errors except it asking me if i meant x=x, which i do. (or dont depends on your answers :/)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class terraingen : MonoBehaviour {
public GameObject gameobject;
public float gridx = 0f;
public float gridy = 0f;
public float level = 0f;
public float spacing = 0f;
public void Start()
{
float retx = 0f;
float retz = 0f;
for (float y = 0f; y < gridy; y = y + spacing)
{
for (float x = retx; x < gridx; x = x)
{
Vector3 pos = new Vector3(x, retz, y) * spacing;
Instantiate(gameobject, pos, Quaternion.identity);
if (y == gridy)
{
retx = retx + spacing;
y = 0f;
}
else if (retx == gridx)
{
retz = retz + spacing;
retx = 0f;
}
else if (retz > level)
{
break;
}
}
}
}
}