Hi.
Ich programmiere gerade ein Spiel für mein W-Seminar.
Dabei habe ich momentan das Problem das bei meinem Jump n' Run nicht nur ein Gegner kommt sondern eine ganze Schlange übereinanderliegender Gegner. modern-gaming.net/attachment/6437/
modern-gaming.net/attachment/6438/
C: spawner.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Spawner : MonoBehaviour {
[System.Serializable]
public class Wave{
public Transform obstacle;
public int amount;
public float rate;
}
public Wave[] waves;
private int nextWave = 0;
public float delay = 5f;
public float countdown = 5f;
void Start(){
}
void Update(){
if (countdown <= 0) {
StartCoroutine (SpawnWave (waves [nextWave]));
} else {
countdown -= Time.deltaTime;
}
}
IEnumerator SpawnWave(Wave _wave){
for(int i = 0; i < _wave.amount; i++){
Instantiate (_wave.obstacle, transform.position, transform.rotation);
Debug.Log ("OBSTACLE SPAWNED");
yield return new WaitForSeconds (1f/_wave.rate);
}
yield break;
}
}
Alles anzeigen
Hoffe auf schnelle Hilfe
Mfg
Admiral CrazyMarcel