Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hey I would try to access the horizontal movement only when the player is doing a jump. Something like
- if (CrossPlatformInputManager.GetButtonDown("Jump") && hasJumps > 0)
- {
- double jumpHorizontalVelocity;
- if (CrossPlatformInputManager.GetButtonDown("MoveRight")) {
- jumpHorizontalVelocity = jumpHorizontalSpeed;
- } else if (CrossPlatformInputManager.GetButtonDown("MoveLeft")) {
- jumpHorizontalVelocity = -jumpHorizontalSpeed;
- }
- Vector2 jumpVelocityToAdd = new Vector2(0f, jumpSpeed);
- myRigidBody.velocity += jumpVelocityToAdd;
- myRigidBody.velocity.x = jumpHorizontalVelocity;
- isJumping = true;
- --hasJumps;
- }
- if (!myFeet.IsTouchingLayers(LayerMask.GetMask("Ground"))) { return; }
- {
- hasJumps = 1;
- isJumping = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement