Advertisement
Guest User

Untitled

a guest
May 12th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. public class FigureSwitch : MonoBehaviour
  2. {
  3.     void Start()
  4.     {
  5.     }
  6.     void Update()
  7.     {
  8. // Если так то создается с умножение на количество объектов уже созданных
  9.         if (Input.GetKeyDown(KeyCode.W))
  10.         {
  11.             FindObjectOfType<SpawnerFigure>().Respawn();
  12.         }
  13.     }
  14. }
  15. //Если напрямую то создается по штучке;
  16. public class SpawnerFigure : MonoBehaviour
  17. {
  18.     public GameObject[] groups = new GameObject[3];
  19.  
  20.     void Start()
  21.     {
  22.         Respawn();
  23.     }
  24.     void Update()
  25.     {
  26.         if (Input.GetKeyDown(KeyCode.R))
  27.         {
  28.             Respawn();
  29.         }
  30.     }
  31.     public void Respawn()
  32.     {
  33.         float a = 0;
  34.         float b = 0;
  35.         Vector3 respawn = new Vector3(a, b, 0);
  36.         int i = Random.Range(0, groups.Length);
  37.         Instantiate(groups[i], respawn, Quaternion.identity);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement