Question by
Sp33dyTurtle · Mar 14, 2018 at 11:13 PM ·
errorcrashproblem during runtime
Unity crashes whenever i activate my script... ,I have a script that crashes whenever i activate it....
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class OilRigSpawnGen : MonoBehaviour {
//public List<GameObject> units = new List<GameObject>();
public GameObject waterTiles;
void Update()
{
if (Input.GetKeyDown(KeyCode.G))
{
for (int x = 0; x < 3; x++)
{
for (int z = 0; z < 3; z++)
{
this.gameObject.transform.position = new Vector3(gameObject.transform.position.x,0, gameObject.transform.position.z);
GameObject tileClone = Instantiate(waterTiles.gameObject, new Vector3(transform.position.x - (55 * x), 0, transform.position.z - (55 * z)), Quaternion.identity) as GameObject;
//units.Add(tileClone.gameObject);
}
}
}
}
}
Comment
Answer by meat5000 · Mar 14, 2018 at 11:22 PM
I tested your code and it doesnt crash. Maybe you are spawning too complex a model. I tested with cylinders and it makes a very widely spaced out grid of 9.