Hi there… so I have created an object that spawns hazards continuously in a loop… you can control how wide the spawn length is… but you i can’t seem to move it around… here is the code i’ve written.
using UnityEngine;
using System.Collections;
public class CloudScript : MonoBehaviour
{
public GameObject hazard;
public Vector3 spawnValues;
public int rainCount;
public float spawnWait;
public float startWait;
void Start ()
{
StartCoroutine (SpawnWaves ());
}
IEnumerator SpawnWaves ()
{
yield return new WaitForSeconds (startWait);
while (true)
{
for(int i = 0; i < rainCount; i++)
{
Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), 1, 1);
Quaternion spawnRotation = Quaternion.identity;
Instantiate (hazard, spawnPosition, spawnRotation);
yield return new WaitForSeconds (spawnWait);
}
}
}
}
Here is the problem i’m facing… the script is attached to the cloud… but when you move the cloud… the spawn position stays the same…