Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float movementSpeed = 0.1f;
- public float jumpSpeed = 10.0f;
- private bool isJumping = false;
- private bool isFalling = false;
- // Get Input and Move player
- void getInput()
- {
- float moveX = Input.GetAxis ("Horizontal") * movementSpeed;
- float moveZ = Input.GetAxis ("Vertical") * movementSpeed;
- transform.Translate(moveX, 0, moveZ);
- if ((Input.GetButtonDown("Jump")) && (isJumping == false) && (isFalling == false))
- {
- rigidbody.velocity = new Vector3(0,jumpSpeed,0);
- isJumping = true;
- }
- if ((rigidbody.velocity.y < -0.1f) && isJumping)
- {
- isJumping = false;
- isFalling = true;
- }
- if ((Mathf.Abs(rigidbody.velocity.y) < 0.1f) && isFalling )
- {
- isFalling = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment