using UnityEngine;
using System.Collections;
public class SpawnerInParent : MonoBehaviour {
public GameObject[] testObject;
public float xRange = 1.0f;
public float zRange = 1.0f;
public float minSpawnTime = 1.0f;
public float maxSpawnTime = 10.0f;
// Use this for initialization
public void Start ()
{
Invoke ("SpawnItem", Random.Range (minSpawnTime, maxSpawnTime));
}
// Update is called once per frame
void SpawnItem ()
{
float xOffset = Random.Range (-xRange, xRange);
float zOffset = Random.Range (-zRange, zRange);
int spawnObjectIndex = Random.Range(0, testObject.Length);
GameObject goInst = (GameObject) Instantiate (testObject [spawnObjectIndex], transform.position + new Vector3 (xOffset, zOffset, 0.0f), testObject [spawnObjectIndex].transform.rotation);
goInst.transform.parent = transform;
Invoke ("SpawnItem", Random.Range (minSpawnTime, maxSpawnTime));
}
}
I was using this code to spawn along x and y axis worked perfectly. Now I need it to spawn along x and z axis…So I changed y axis to z but it still spawns along the y axis? Help please?