Advertisement
Guest User

Untitled

a guest
Sep 24th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SpriteMover : MonoBehaviour {
  5.  
  6. // Use this for initialization
  7. void Start () {
  8.  
  9. }
  10.  
  11. // Update is called once per frame
  12. void Update () {
  13. {
  14. if ((Input.GetKey(KeyCode.LeftShift)))
  15. {
  16. if(Input.GetKeyDown(KeyCode.LeftArrow)){
  17. Vector3 position = this.transform.position;
  18. position.x--;
  19. this.transform.position = position;
  20. }
  21.  
  22. if(Input.GetKeyDown(KeyCode.RightArrow)){
  23. Vector3 position = this.transform.position;
  24. position.x++;
  25. this.transform.position = position;
  26. }
  27.  
  28. if(Input.GetKeyDown(KeyCode.UpArrow)){
  29. Vector3 position = this.transform.position;
  30. position.y++;
  31. this.transform.position = position;
  32. }
  33.  
  34. if(Input.GetKeyDown(KeyCode.DownArrow)){
  35. Vector3 position = this.transform.position;
  36. position.y--;
  37. this.transform.position = position;
  38. }
  39. } else {
  40. if (Input.GetKey(KeyCode.LeftArrow)) {
  41. Vector3 position = this.transform.position;
  42. position.x--;
  43. this.transform.position = position;
  44. }
  45. if (Input.GetKey(KeyCode.RightArrow)) {
  46. Vector3 position = this.transform.position;
  47. position.x++;
  48. this.transform.position = position;
  49. }
  50. if (Input.GetKey(KeyCode.UpArrow)) {
  51. Vector3 position = this.transform.position;
  52. position.y++;
  53. this.transform.position = position;
  54. }
  55. if (Input.GetKey(KeyCode.DownArrow)) {
  56. Vector3 position = this.transform.position;
  57. position.y--;
  58. this.transform.position = position;
  59. }
  60. }
  61.  
  62. if ((Input.GetKey(KeyCode.RightShift)))
  63. {
  64. if(Input.GetKeyDown(KeyCode.LeftArrow)){
  65. Vector3 position = this.transform.position;
  66. position.x--;
  67. this.transform.position = position;
  68. }
  69.  
  70. if(Input.GetKeyDown(KeyCode.RightArrow)){
  71. Vector3 position = this.transform.position;
  72. position.x++;
  73. this.transform.position = position;
  74. }
  75.  
  76. if(Input.GetKeyDown(KeyCode.UpArrow)){
  77. Vector3 position = this.transform.position;
  78. position.y++;
  79. this.transform.position = position;
  80. }
  81.  
  82. if(Input.GetKeyDown(KeyCode.DownArrow)){
  83. Vector3 position = this.transform.position;
  84. position.y--;
  85. this.transform.position = position;
  86. }
  87. } else {
  88. if (Input.GetKey(KeyCode.LeftArrow)) {
  89. Vector3 position = this.transform.position;
  90. position.x--;
  91. this.transform.position = position;
  92. }
  93. if (Input.GetKey(KeyCode.RightArrow)) {
  94. Vector3 position = this.transform.position;
  95. position.x++;
  96. this.transform.position = position;
  97. }
  98. if (Input.GetKey(KeyCode.UpArrow)) {
  99. Vector3 position = this.transform.position;
  100. position.y++;
  101. this.transform.position = position;
  102. }
  103. if (Input.GetKey(KeyCode.DownArrow)) {
  104. Vector3 position = this.transform.position;
  105. position.y--;
  106. this.transform.position = position;
  107. }
  108. }
  109.  
  110.  
  111. if (Input.GetKey (KeyCode.Space))
  112. {
  113. this.transform.position = new Vector3 (0f, 0f, 0f);
  114. }
  115. }
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement