spawn bigger objects at times
I'm making a asteroid game where asteroid come in from each side of my game. There's no problem with my spawning script i just want to know how can i make my spawning script spawn bigger objects randomly. You know it spawns my object small then it spawn big ones sometimes but still spawning the small ones. (Sorry if I'm not making sense right now) here's my script:
using UnityEngine;
using System.Collections;
public class Sidespawn : MonoBehaviour {
public GameObject ObjectToSpawn;
public float RateOfSpawn = 1;
public float SpawnDelay = 20f;
private float nextSpawn = 0;
// Update is called once per frame
void Update () {
if (Time.time > nextSpawn) {
nextSpawn = Time.time + RateOfSpawn;
}
}
void Start(){
Invoke("Spawn", SpawnDelay);
}
void Spawn () {
// Random position within this transform
Vector3 rndPosWithin;
rndPosWithin = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f));
rndPosWithin = transform.TransformPoint(rndPosWithin * .5f);
Instantiate(ObjectToSpawn, rndPosWithin, transform.rotation);
Invoke("Spawn",SpawnDelay);
}
}
Answer by hexagonius · Oct 17, 2015 at 09:22 PM
save the returned gameobject of the Instantiated asteroid in a temporary variable. set its scale to a random multiple times Vector3.one
I'm sorry but can you extend your explanation a bit more @hexagonius
And thank you for answering so fast. I really appreciate it
Your answer

Follow this Question
Related Questions
Wave spawner script 2 Answers
Spawning Bug. 1 Answer
Player spawn in the center of the world 2 Answers
How to drop a box 0 Answers
error CS1526: A new expression requires () or [] after type 1 Answer