# Thread: Wall jump bug that is hard to fix.

1. ## Wall jump bug that is hard to fix.

Hi guys this is a very important request. The problem this time is that in my engine i created a wall jump function which works but with one stupid problem which i tried countless times to resolve, that problem is that when i wall jump the jump works fine but if i wall jump and my character is in the air, there is some kind of gravitational pull that keeps making him go left and he wont stop unless i do a wall slide. Sorry if its hard to explain, here is my engine since its easier to understand once you encounter it.

Rockman X Engine Version 0.0.2 Dash and Custom Engine.mfa

2. Hi there. I found out what the problem is. When wall jumping, you set the x movement speed (horizontal) to either 7 or -7. The event that causes the speed to decrease does so by moving the speed towards 0 in steps of 3.

There are two events that causes the horizontal speed to move towards 0:

Event A

X Left arrow is pressed
X Right arrow is pressed
Horizontal of Colider < 0

Event B

X Left arrow is pressed
X Right arrow is pressed
Horizontal of Colider > 0

> Subtract 3 from horizontal

So, when jumping left from a wall:

1. game sees that the speed is negative, and adds 3 to it (horizontal is now -4) (event A) game loop 1

2. game sees that the speed is negative, and adds 3 to it (horizontal is now -1). (event A) game loop 1

3. game sees that the speed is negative, and adds 3 to it (horizontal is now 2). (event A) game loop 1

4. game sees that the speed is positive, and subtracts 3 from it (horizontal is now -1). (event B) game loop 1

5. game sees that the speed is negative, and adds 3 to it (horizontal is now 2). (event A) game loop 2

6. game sees that the speed is positive, and subtracts 3 from it (horizontal is now -1). (event B) game loop 2

Since event B is placed below event A, it will always make sure that horizontal ends up at -1 (resulting in the character sliding to the left). Horizontal never reaches 0 since the events make jumps by 3.

When jumping right from a wall:

1. game sees that the speed is positive, and subtracts 3 from it (horizontal is now 4) (event B) game loop 1

2. game sees that the speed is positive, and subtracts 3 from it (horizontal is now 1). (event B) game loop 1

3. game sees that the speed is positive, and subtracts 3 from it (horizontal is now -2). (event B) game loop 1

4. game sees that the speed is negative, and adds 3 to it (horizontal is now 1). (event A) game loop 2

5. game sees that the speed is positive, and subtracts 3 from it (horizontal is now -2). (event B) game loop 2

Since event B is placed below event A, it will always make sure that horizontal ends up at -2 (resulting in the character sliding to the left). Horizontal never reaches 0 since the events make jumps by 3.

The easiest way to solve this problem right now is to set the horizontal to a number that is divisible by 3 after a wall jump is made (6/-6 instead of 7/-7 for example).

I would however suggest that you solve the retardation in some other way. One way is to change event A (and B) like this:

Event A

X Left arrow is pressed
X Right arrow is pressed
Horizontal of Colider < 0

>Add 1 to horizontal (this will always end up at 0, unless you force horizontal into becoming a float number by doing some kind of division - beware of that).

Event B

X Left arrow is pressed
X Right arrow is pressed
Horizontal of Colider > 0

>Subtract 1 from horizontal

Or even simpler:

Event A (remove Event B)

X Left arrow is pressed
X Right arrow is pressed
Horizontal of Colider <> 0

> Set horizontal to 0

I hope this made some kind of sense Just ask if there is anything else you wonder about.

3. I knew that i created a complete mess , i couldn't sleep because i knew its a big problem. Thank you Yima, your a lifesaver as always , i shall try it out and see what happens.

4. Yima..... it WORKS LIKE A CHARM !!! Thank you alot , thanks for helping get rid of the problem. You really are a lifesaver.

5. No problem - just happy to help!