Question by
Speshimen · Jun 12, 2017 at 09:03 AM ·
2dscripting problemgameobjectinstantiaterandom spawn
Instantiating object randomly withing the boundaries of an object.
Im trying to spawn an object called Asteroid in a random location within the boundaries of the green area with an interval. I can't figure out what i'm supposed to write in the Instantiation code. Could someone please help me?
public class SpawnerScript : MonoBehaviour {
public float SpawnRate = 3;
private float NextSpawn;
public GameObject Asteroid;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Time.time > NextSpawn)
{
NextSpawn = Time.time + SpawnRate;
Instantiate(Asteroid,???
}
}
}
Comment
Your answer
Follow this Question
Related Questions
GameObject wont correctly instantiate into an array 1 Answer
Add Component with Script Data 1 Answer
Instantiate() and Destroy() vs setActive() 1 Answer
Game Object doesn't instantiate at Mouse Position 3 Answers
RPG instantiate problem 3 Answers