- Home /
Question by
glok92 · Mar 15, 2015 at 07:01 PM ·
c#gameobjectgamesc# tutorial
C# Unity , How I Can Increase speed of game-object in Y axis in (spawn wave) pair time unit ??
C# Unity , How I Can Increase speed of game-object in Y axis in (spawn wave) pair time unit ??
this is my code :
for a color game have 2 color
using UnityEngine; using System.Collections;
[System.Serializable] public class red { public GameObject redballObj;
public int Count;
public float Spawnwait;
public float Startwait;
public float Wavewait;
} [System.Serializable] public class blue {
public GameObject blueballObj;
public int Count;
public float Spawnwait;
public float Startwait;
public float Wavewait;
}
public class gamecontrol_script : MonoBehaviour { public red red; public blue blue; public Vector2 SpawnValues;
// Use this for initialization
void Start () {
StartCoroutine (redSpawnWaves());
StartCoroutine (blueSpawnWaves());
}
IEnumerator redSpawnWaves ()
{
yield return new WaitForSeconds (red.Startwait);
while (true) {
for (int i = 0; i< red.Count; i++) {
Vector2 SpawnPosition = new Vector2
(Random.Range (-SpawnValues.x, SpawnValues.x), SpawnValues.y);
Quaternion spawnRotation = Quaternion.identity;
Instantiate (red.redballObj, SpawnPosition, spawnRotation);
//Instantiate (rocks.blueballObj, SpawnPosition, spawnRotation);
yield return new WaitForSeconds (red.Spawnwait);
}
yield return new WaitForSeconds (red.Wavewait);
}
}
IEnumerator blueSpawnWaves (){
yield return new WaitForSeconds (blue.Startwait);
while(true)
{
for (int i = 0; i< blue.Count; i++)
{
Vector2 SpawnPosition = new Vector2
(Random.Range (-SpawnValues.x, SpawnValues.x) , SpawnValues.y);
Quaternion spawnRotation = Quaternion.identity ;
Instantiate (blue.blueballObj, SpawnPosition, spawnRotation);
yield return new WaitForSeconds (blue.Spawnwait);
}
yield return new WaitForSeconds (blue.Wavewait);
}
}
// Update is called once per frame
void Update () {
}
}
Comment
Your answer
Follow this Question
Related Questions
Array of colliders/triggers 0 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
change a gameobject into another 1 Answer
Get game component type? 1 Answer