I am attempting to make drops fall from the sky, but to start I only want a couple. This is my code:
using UnityEngine;
using System.Collections;
public class DropMovement : MonoBehaviour {
public float MinX = -9.4f;
public float MaxX = 9.4f;
public GameObject dropPrefab;
public int numberOfDrops;
private int a;
private void spawnDrops()
{
Vector3 newPos = new Vector3(Random.Range(MinX,MaxX),7.5f,0);
GameObject drop = Instantiate(dropPrefab, newPos, Quaternion.identity) as GameObject;
}
void Start()
{
for (int a = 0; a < numberOfDrops; a++)
{
spawnDrops();
}
}
}
When I run it, hundreds of drops fall from the sky and I cant seem to control the number of them. I think the problem is with the for loop but I am not sure, help is much appreciated.