Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. float jumpForce = 500f;
  2. public bool IsJumping { get; set; }
  3.  
  4. private bool isGrounded;
  5. public Transform groundCheck;
  6. public float checkRadius;
  7. public LayerMask whatIsGround;
  8.  
  9.  
  10.  
  11. IsJumping = Input.GetKeyDown (KeyCode.Space);
  12.  
  13.  
  14.  
  15. if (isGrounded == true)
  16. {
  17.  
  18. if (IsJumping)
  19. {
  20. DoJump ();
  21. }
  22. }
  23.  
  24.  
  25. public void DoJump ()
  26. {
  27. rb.AddForce (Vector2.up * jumpForce);
  28. }
  29.  
  30. isGrounded = Physics2D.OverlapCircle (groundCheck.position, checkRadius, whatIsGround);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement