Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. void Update()
  2. {
  3. if (m_Color == PlayerType.Blue)
  4. {
  5. moveLeft = Input.GetKey("a");
  6. moveRight = Input.GetKey("d");
  7. moveDown = Input.GetKey("s");
  8. }
  9.  
  10. if (m_Color == PlayerType.Red)
  11. {
  12. moveRight = Input.GetKey("right");
  13. moveLeft = Input.GetKey("left");
  14. moveDown = Input.GetKey("down");
  15. }
  16. if (m_Color == PlayerType.Yellow)
  17. {
  18. moveLeft = Input.GetKey("h");
  19. moveRight = Input.GetKey("k");
  20. moveDown = Input.GetKey("j");
  21. }
  22. if (m_Color == PlayerType.Green)
  23. {
  24. moveLeft = Input.GetKey("[4]");
  25. moveRight = Input.GetKey("[6]");
  26. moveDown = Input.GetKey("[5]");
  27. }
  28.  
  29. Vector3 NewPos = transform.position;
  30. if (moveLeft)
  31. {
  32. NewPos += new Vector3(-MoveSpeed*Time.deltaTime, 0, 0);
  33. }
  34. if (moveRight)
  35. {
  36. NewPos += new Vector3(MoveSpeed * Time.deltaTime, 0, 0);
  37. }
  38. if (moveDown)
  39. {
  40. NewPos += transform.forward * MoveSpeed * Time.deltaTime;
  41. }
  42. rb.MovePosition(NewPos);
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement