Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FigureSwitch : MonoBehaviour
- {
- void Start()
- {
- }
- void Update()
- {
- // Если так то создается с умножение на количество объектов уже созданных
- if (Input.GetKeyDown(KeyCode.W))
- {
- FindObjectOfType<SpawnerFigure>().Respawn();
- }
- }
- }
- //Если напрямую то создается по штучке;
- public class SpawnerFigure : MonoBehaviour
- {
- public GameObject[] groups = new GameObject[3];
- void Start()
- {
- Respawn();
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.R))
- {
- Respawn();
- }
- }
- public void Respawn()
- {
- float a = 0;
- float b = 0;
- Vector3 respawn = new Vector3(a, b, 0);
- int i = Random.Range(0, groups.Length);
- Instantiate(groups[i], respawn, Quaternion.identity);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement