Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public class PlayerController : MonoBehaviour {
  2.  
  3. private Animator animator;
  4.  
  5.  
  6.  
  7. void Start()
  8. {
  9.  
  10. }
  11.  
  12.  
  13. void Update()
  14. {
  15. Flip();
  16. movement();
  17.  
  18.  
  19. }
  20.  
  21. void movement()
  22. {
  23.  
  24. if (Input.GetKey(KeyCode.S))
  25. {
  26. this.transform.position += new Vector3(0f, -0.04f, 0f);
  27. }
  28. if (Input.GetKey(KeyCode.W))
  29. {
  30. this.transform.position += new Vector3(0f, 0.04f, 0f);
  31. }
  32. if (Input.GetKey(KeyCode.D))
  33. {
  34. this.transform.position += new Vector3(0.04f, 0f, 0f);
  35. }
  36. else if (Input.GetKey(KeyCode.A))
  37. {
  38. this.transform.position += new Vector3(-0.04f, 0f, 0f);
  39.  
  40. }
  41.  
  42. }
  43.  
  44. void Flip()
  45. {
  46. if (Input.GetKey(KeyCode.S))
  47. {
  48. this.transform.localScale = new Vector3(1, 1, 1);
  49. }
  50. if (Input.GetKey(KeyCode.W))
  51. {
  52. this.transform.localScale = new Vector3(1, 1, 1);
  53. }
  54. if (Input.GetKey(KeyCode.A))
  55. {
  56. this.transform.localScale = new Vector3(-1, 1, 1);
  57. }
  58. if (Input.GetKey(KeyCode.D))
  59. {
  60. this.transform.localScale = new Vector3(1, 1, 1);
  61. }
  62.  
  63. }
  64.  
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement