I am working on a football game project. I want a sphere I have to spawn another sphere after I throw the 1st sphere. Here's something I tried:
public class spawn : MonoBehaviour {
public Transform[] SpawnPoints;
public float SpawnTime;
public GameObject ball;
// Use this for initialization
void Start () {
InvokeRepeating ("SpawnBalls", SpawnTime, SpawnTime);
}
void SpawnBalls(){
if (transform.position.z > -0.904 ) {
int SpawnIndex = Random.Range (0, SpawnPoints.Length);
Instantiate (ball, SpawnPoints [SpawnIndex].position, SpawnPoints [SpawnIndex].rotation);
}
}
}