Jump to content

Getting caught on walls, p2 platformer


DazZ
 Share

Recommended Posts

I'm currently making a platformer, and my code is somewhat similar to this example.

 

The problem is if you jump into the wall you can get stuck onto it, and from there jump again essentially climbing the wall when you should be sliding down it.

 

Is there anything simple I can try that I'm not thinking of?

Link to comment
Share on other sites

there is no solution to this problem from the framework side...  gravity should always pull you down despite the friction between the player and the wall material, even if a force into the direction of the wall is still applied...  (the wall is on the left side and the player is moving to the left so it gets stuck on the wall - the player should fall down the moment you stop walking to the left - in some very rare cases the player stays on it's place on the wall..)   is that your problem??

 

if so you could work with materials..  configure all walls to act like an ice material with 0 friction.. then the player should slide down

 

in my game i always check if the player is in the air (not touching ground) and then i change the player material into ice material with 0 friction to all other materials..

Link to comment
Share on other sites

(the wall is on the left side and the player is moving to the left so it gets stuck on the wall - the player should fall down the moment you stop walking to the left - in some very rare cases the player stays on it's place on the wall..)   is that your problem??

 

No you have to be trying to do it and if you stop moving you do fall, but if you're still holding left into a wall and you will "stand" on it if in the right place, allowing you to jump. However it's not rare enough so I can easily scale high walls with nothing sticking out of them, as whilst you're "standing" on the wall you can jump (at least you can in the example and my code).

 

I'll give the ice friction a go, but I think if I was still moving into the wall that wouldn't effect it? I'll go find out.

Link to comment
Share on other sites

that's exactly what i've been trying to describe..    you will get rid of the effect when you reduce the friction between the walls and your player to 0   but the walljumps shouldn't happen at all..  i've never had this problem with the function from the example that checksIfcanJump..

 

maybe it is because i use a circle instead of a rectangle for my player..   i would try to use the "setCircle()" function to change the physics body of your player to a circle too!

Link to comment
Share on other sites

that's exactly what i've been trying to describe..    you will get rid of the effect when you reduce the friction between the walls and your player to 0   but the walljumps shouldn't happen at all..  i've never had this problem with the function from the example that checksIfcanJump..

 

maybe it is because i use a circle instead of a rectangle for my player..   i would try to use the "setCircle()" function to change the physics body of your player to a circle too!

 

The zero friction did help even with a rectangle body, but didn't get rid of it completely. I could only get it to stick to the wall once though so I couldn't climb walls anymore.

 

However the circle completely removed any wall stick issues, and also made my slopes which I think came from one of your examples work a lot more smoothly as well.

 

Thanks!

Link to comment
Share on other sites

the thing is..  this doesn't resolve the problem completely.. but it is then rare enough to forget about it.. 

 

another thing you can do (and i did) is to get rid of the "gaps" between the tiles..  all my tiles are painted on the background and on object layers i define the collision areas.. so i have hughe plain collision areas without "gaps" between every tile - i think this reduces the effect even more and btw. is more performant..  i have only two visible layers and this is very good for the scrolling performance..

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...