Wall sliding


I'd like to set up collisions for my game in such a way that if you were to push up against a wall at an angle your avatar would slide along the wall … if you get my meaning. Right now you just stop entirely - and it can be awkward navigating small spaces as if you bash into a wall you'll often have to backup and turn around.

I was just wondering if anyone had some insight into how this would be done. I was thinking about firing a ray off at an angle to the left and right of a player and working out … something … I haven't thought it through so much but I figured there might be a better way than whatever-it-is that I'm thinking but can't put into words.  :stuck_out_tongue:

Well I use jbullet for the player movement.

I have a similar issue right now in fact, so glad you brought this up.

My suggestion (but I haven't tried it yet) is to break the movement up in to two pieces. The forward/backward, and the left/right. Do collision checks for forwards/backwards (and move if allowed). Then do a collision check for the left/right (and again move if allowed).

Let me see if I can get an implementation working on this…

You can do the shoot the ray thing (calc strike angle to offset player movement) but its probably easier to use a physics package.  I have used the simple physics package noted in this thread for wall sliding:


And here's a webstart demo of it in action (in a "lab/test" area):


Its not too tricky to set up.


you use JME1, right? Or did you port SimplePhyiscs successfully to jme2?



mcbeth ported it to jME 2 and that's what I used for the lab/demo stuff. 

Come to think of it, I don't think that it ever got a permenent link on the website or forum.  I think he pm'd an url to me that had the code.

mcbeth: are you out there?  Can you post it or point to the link?

If he's not out there then I can put something together and post it… but it might be a few days before I have any real time to do that.

The math isn't all that hard, so if you are not already using a physics package then just do it all using jME.


simple_physics jme2 perhaps someone can make a more accessible link some where