I have tried to convert this over and over and it never works so I must be doing something wrong. This is the script I am trying to convert:
var block1 : GameObject;
var worldWidth : uint = 5;
var worldHeight : uint = 5;
var spawnSpeed : float = .5;
function Start () {
CreateWorld();
}
function Update () {
}
function CreateWorld() {
for(var x : uint =0; x<worldWidth; x+=1) {
for(var z : uint =0; z<worldHeight; z+=1) {
var block = Instantiate(block1);
block.transform.position = new Vector3(this.transform.position.x + x, this.transform.position.y, this.transform.position.z + z);
}
}
}
Here is the C# version when I try to use it it does nothing.
using UnityEngine;
using System.Collections;
public class WorldSpawn : MonoBehaviour {
public GameObject block1;
uint worldWidth = 5;
uint worldHeight = 5;
float spawnSpeed = 1;
void Start (){
CreateWorld();
}
IEnumerator CreateWorld (){
for(uint x =0; x<worldWidth; x+=1) {
yield return new WaitForSeconds(spawnSpeed);
for(uint z =0; z<worldHeight; z+=1) {
yield return new WaitForSeconds(spawnSpeed);
var block= Instantiate(block1);
block1.transform.position = new Vector3(this.transform.position.x + x, this.transform.position.y, this.transform.position.z + z);
}
}
}
}