GooseZA Posted February 24, 2014 Share Posted February 24, 2014 Hi all, I'm trying to get wall jumping working in my little platformer. When the player jumps into a vertical wall, I want him to slide down slowly and then if jump is pressed while he's still on the wall, a horizontal jump in the opposite direction is performed.I'm trying to check using body.onWall() to see if the player can walljump but this property only seems to be true for the initial contact. After that it is false. I assume on collision the player is probably being separated from the wall. Any other ideas on how to do this? Link to comment Share on other sites More sharing options...
Heppell08 Posted February 24, 2014 Share Posted February 24, 2014 As soon as the instant turns true for the second, use the update to set up the stuff needed there and then for the jump, gravity, a timer etc etc.Just a hunch though. Link to comment Share on other sites More sharing options...
srikarg Posted February 24, 2014 Share Posted February 24, 2014 There was a thread posted on this topic a while back. It might help: http://www.html5gamedevs.com/topic/3510-wall-jump-ideas/. Link to comment Share on other sites More sharing options...
moe091 Posted February 25, 2014 Share Posted February 25, 2014 on the collision callback with the wall have an onWall var that you set to true, also save the x position of the sprite at that point. Then when the player presses the F key check if onWall is true, if it is check if the players current x position is equal to(or within a reasonable range) to the original x position when it hit the wall, if it is let him jump and if it isn't set onWall = false. you could do this with 1 variable as well, only using the xPosition variable and setting it to -1 for false(or some other sentinel value if -1 is a valid x position in your game) and any number greater than 0 for positive, so it can be used to keep track of the x position and the onWall boolean. this solution won't work for some cases though and will require a couple extra checks for edge cases, e.g when the player hits a wall then slides down off the bottom without changing position on the x-axis. Not sure if this is the greatest solution but it's just what came to me and it sounds like it should work. GooseZA 1 Link to comment Share on other sites More sharing options...
GooseZA Posted February 25, 2014 Author Share Posted February 25, 2014 Thanks for the replies guys. Will try them out =) Link to comment Share on other sites More sharing options...
GooseZA Posted February 25, 2014 Author Share Posted February 25, 2014 on the collision callback with the wall have an onWall var that you set to true, also save the x position of the sprite at that point. Then when the player presses the F key check if onWall is true, if it is check if the players current x position is equal to(or within a reasonable range) to the original x position when it hit the wall, if it is let him jump and if it isn't set onWall = false. This did the trick. When he was on wall, I saved his position and set canWallJump boolean to true. If jump was pressed after that, I checked if he was withing a reasonable range of the saved x Position and then let them jump Thanks again =) Link to comment Share on other sites More sharing options...
Recommended Posts