Advertisement
Guest User

jump script

a guest
Oct 7th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. void Update()
  2.     {
  3.  
  4.         grounded = Physics2D.IsTouchingLayers(myCollider, whatIsGround);
  5.  
  6.         myRigidbody.velocity = new Vector2(moveSpeed, myRigidbody.velocity.y);
  7.  
  8.         if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
  9.         {
  10.             if (grounded)
  11.             {
  12.                 myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce);
  13.             }
  14.         }
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement