Advertisement
Guest User

Untitled

a guest
May 12th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. public class FigureSwitch : MonoBehaviour
  2. {
  3.     void Start()
  4.     {
  5.  
  6.     }
  7.     void Update()
  8.     {
  9. // If so, it is created with multiplication by the number of objects already created
  10.         if (Input.GetKeyDown(KeyCode.W))
  11.         {
  12.             FindObjectOfType<SpawnerFigure>().Respawn();
  13.         }
  14.     }
  15. }
  16.  
  17. public class SpawnerFigure : MonoBehaviour
  18. {
  19.     public GameObject[] groups = new GameObject[3];
  20.  
  21.     void Start()
  22.     {
  23.         Respawn();
  24.     }
  25.     void Update()
  26.     {
  27.   //One object is created directly
  28.         if (Input.GetKeyDown(KeyCode.R))
  29.         {
  30.             Respawn();
  31.         }
  32.     }
  33.     public void Respawn()
  34.     {
  35.         float a = 0;
  36.         float b = 0;
  37.         Vector3 respawn = new Vector3(a, b, 0);
  38.         int i = Random.Range(0, groups.Length);
  39.         Instantiate(groups[i], respawn, Quaternion.identity);
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement