Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. // Checks if player is pressing movement keys, if is applies force to specified direction
  2. if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
  3. {
  4. //rigid.AddForce(new Vector2(-speed * Time.deltaTime, 0));
  5. rigid.AddRelativeForce(Vector2.left);
  6. }
  7.  
  8. if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
  9. {
  10. //rigid.AddForce(new Vector2(speed * Time.deltaTime, 0));
  11. rigid.AddRelativeForce(Vector2.right);
  12. }
  13.  
  14. if (Input.GetKey(KeyCode.UpArrow) && groundCheck.isGrounded == false || Input.GetKey(KeyCode.W) && groundCheck.isGrounded == false || Input.GetKey(KeyCode.Space) && groundCheck.isGrounded == false)
  15. {
  16. groundCheck.isGrounded = false;
  17. //rigid.AddRelativeForce(new Vector2(0, jumpPower));
  18. rigid.velocity = new Vector2(rigid.velocity.x, jumpPower);
  19. }
  20.  
  21. double worldRotation;
  22.  
  23. void rotateLeft()
  24. {
  25. worldRotation = (worldRotation + 90) % 90;
  26. }
  27.  
  28. if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
  29. {
  30. rigid.AddRelativeForce(Vector2.left.Rotate(worldRotation));
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement