- Home /
Too subjective and argumentative
How Increase And Decrease And Reset Spawn Rate Over
Hi How I Can Increase And Decrease Spawn Rate Every Time I Want? My Code Work Just For Increase Not Decrease Or Reset!
public float nextDrop = 0f; public float dropInterval = 2f; public float changeInterval = 5f; float delay = 3f; int minX = -6; int maxX = 6; int direction; int indexx; public Vector3 spawnvalue; public Transform fireworkY; public GameObject explosion; public GameObject speedparticla; public GameObject yourloseTable; public GameObject TestEffect; public GameObject[] targets; public Canvas touch; bool gameOver = false; public static bool SpawnGo; public Text theyarecoming; public Text theyarecoming2; public Text ScoreText; public ScoreManager thescore; public AudioClip deathsound; public AudioClip EndGame; public AudioClip FireWorks;
void Start()
{
ScoreText.enabled = true;
SpawnGo = true;
WaterMove.OceanMove = true;
yourloseTable.SetActive(false);
touch.gameObject.SetActive(true);
nextDrop = Time.time + delay;
Pool.index = 0;
Invoke ("Coin", (Random.Range(10f, 50f)));
}
void Update()
{ if(PlayerSelectionGame.index == 0) indexx = 0;
if(PlayerSelectionGame.index == 1)
indexx = 1;
if(PlayerSelectionGame.index == 2)
indexx = 2;
if(SpawnGo)
{
if(Time.time >= nextDrop)
{
Spawn();
nextDrop += dropInterval;
if(Time.timeSinceLevelLoad >= changeInterval)
{
if(dropInterval > 0.3f)
{
dropInterval *= 0.92f;
}
}
if(Time.timeSinceLevelLoad >= 50f)
{
if(dropInterval < 0.3f)
{
dropInterval = 2f;
}
}
if(Time.timeSinceLevelLoad >= 60f)
{
if(dropInterval > 0.3f)
{
dropInterval *= 0.92f;
}
}
if(Time.timeSinceLevelLoad >= 100f)
{
Pool.index = 1;
ShowTextAnimation();
Debug.Log("startwave");
}
if(Time.timeSinceLevelLoad >= 120)
{
Pool.index = 2;
Debug.Log("stoptwave");
}
if(Time.timeSinceLevelLoad >= 160)
{
ShowTextAnimation2();
}
}
}
}
void Spawn()
{
GameObject spawn = Pool.Instance.GetPool();
spawn.transform.position = new Vector3 (Random.Range (minX, maxX), spawnvalue.y, targets[indexx].transform.position.z + 50 );
spawn.SetActive(true);
}
What are the guidelines for writing good questions?
We want Unity Answers to become a comprehensive database of questions and answers related to Unity. When you ask your questions, it can be helpful to keep a few things in $$anonymous$$d:
Don't write things that will be irrelevant in a few days. Writing that "This is urgent!" will probably not get you faster answers, but it may make people frown at your question.
Some reasons for getting a post rejected:
There exists duplicate questions with answers if you were to do a search, either on Answers or on the Forum or on Unity's tutorials
Your question isn't specific enough: asking for a script, asking multiple questions in one post or asking a question that could be either subjective or require extensive discussion
Remake it,
First, posting all the code in correct format
Second, explain, dont only write a sentence and wait to someone to do the work for you
Third, post only relevant code.