Advertisement
Atomic_Violetta

Movement script

Mar 6th, 2024 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | Gaming | 0 0
  1. //Luigi Script
  2. //name
  3.  
  4. using UnityEngine;
  5.  
  6. class LuigiScript : MonoBehaviour
  7. {
  8. // Start is called before the first frame update
  9. protected void Start()
  10. {
  11. // Vectors are variables that mean positions.
  12. Vector3 localWhichPosition;
  13.  
  14. // Luigi is in the middle.
  15. localWhichPosition = Vector3.zero;
  16.  
  17. if (Input.GetKey(KeyCode.LeftArrow))
  18. {
  19. localWhichPosition = 10 * Vector3.left;
  20.  
  21. }
  22. else
  23. if (Input.GetKey(KeyCode.RightArrow))
  24. {
  25. localWhichPosition = 10 * Vector3.right;
  26. }
  27.  
  28. localWhichPosition = Vector3.zero;
  29.  
  30. if (Input.GetKey(KeyCode.UpArrow))
  31. {
  32. localWhichPosition = 10 * Vector3.up;
  33.  
  34. }
  35. else
  36. if (Input.GetKey(KeyCode.DownArrow))
  37. {
  38. localWhichPosition = 10 * Vector3.down;
  39. }
  40.  
  41.  
  42.  
  43. // You have to set the transform position
  44. // to actually change Luigi's position.
  45.  
  46. this.transform.position = localWhichPosition;
  47.  
  48. }
  49.  
  50. // Update is called once per frame
  51. void Update()
  52. {
  53.  
  54. }
  55. }
  56.  
Tags: homework
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement