Hello. I have script that I am using to control the spawn rate of prefabs (written in C#) and I have some other code written in javascript that I am using to control where prefabs spawn. I want to combine these, can someone please translate the javascript to C#? Thank you
//Assumes Vector3's for the minimum and maximum positions
Instantiate(prefab, Vector3(Random.Range(minimum.x,maximum.x),
Random.Range(minimum.y,maximum.y),
Random.Range(minimum.z,maximum.z)),
Quaternion.LookRotation(center));
And, if for some reason its needed here is the C# script
using UnityEngine; using System.Collections;
public class Spawn : MonoBehaviour {
public Transform[] ObjectsToSpawn;
public float SpawnInterval= 15;
public int MaxObjectsSpawned = 8;
public int MinObjectsSpawned = 3;
private float _NextSpawn;
void Start () {
_NextSpawn = Time.time + SpawnInterval;
}
void Update () {
if(Time.time >= _NextSpawn) {
int objectsToSpawn = Random.Range(MinObjectsSpawned, MaxObjectsSpawned);
for (int i = 0; i < objectsToSpawn; i++) {
Instantiate(ObjectsToSpawn[Random.Range(0, ObjectsToSpawn.Length)], transform.position, Quaternion.identity);
}
_NextSpawn = Time.time + SpawnInterval;
}
}
}