Hello everyone,
I am having some kind of bug with my jump. I know it is not, by the way…
Well, when I am grounded and press X, I jump, and in this is case, everything is fine.
But when I am walking and jump, the jump height is serevely reduced based on the velocity (x axis). Also, if I release the key responsible for movement while in mid jump, my character is able to reach the expected and maximum height, which is very strange as the character is suddenly impulsed.
Right now,
I am manipulating each axis separately, like this:
var h : float = Input.GetAxisRaw ("Horizontal");
myRigidbody2D.velocity.x = h * speed;
if (canJump) {
canJump = false;
myRigidbody2D.velocity.y = jumpForce;
}
The reason why I am changing velocity like this and not adding force instead is because it is an arcade platformer and every movement must be fast and sharp. Nonetheless, I have tried adding force instead and the problem persisted, so…
Any help is very appreciated.
Thank you in advance.
- edit: the boolean canJump is being treated on the Update function. This is just a piece of code. The player is able to jump when the X key is pressed, and is grounded. Ir order to be grounded, the player must be colliding with the environment, and the velocity on the y axis must be 0. I did this ir order to avoid that problem when the player might stick to something, like a wall, when falling and walking toward it.