Guest User

Untitled

a guest
Nov 18th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public GameObject UpArrow;
  2. public GameObject DownArrow;
  3. public GameObject LeftArrow;
  4. public GameObject RightArrow;
  5.  
  6. float randomNumber;
  7.  
  8. // Use this for initialization
  9. void Start()
  10. {
  11. }
  12.  
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. if (Input.GetKeyDown (KeyCode.DownArrow)) {
  17. randomNumber = Random.Range (7f, -7f); // this means use a random number between 7f and 0f
  18. Instantiate (DownArrow, new Vector3 (randomNumber, 6f, -6f), Quaternion.identity);
  19. }
  20. if (Input.GetKeyDown (KeyCode.UpArrow)) {
  21. randomNumber = Random.Range (-7f, 7f);
  22. Instantiate (UpArrow, new Vector3 (randomNumber, -6f, 6f), Quaternion.identity);
  23. }
  24. if (Input.GetKeyDown (KeyCode.LeftArrow)) {
  25. randomNumber = Random.Range (7f, -7f);
  26. Instantiate (LeftArrow, new Vector3 (7f, randomNumber, -7f), Quaternion.identity);
  27. }
  28. if (Input.GetKeyDown (KeyCode.RightArrow)) {
  29. randomNumber = Random.Range (-7f, 7f);
  30. Instantiate (RightArrow, new Vector3 (-7f, randomNumber, -7f), Quaternion.identity);
  31. }
  32. }
Add Comment
Please, Sign In to add comment