Jump to content

Physics.P2 How to make player stick to the ground


ZoomBox
 Share

Recommended Posts

Hello :-)

 

I'm making a platformer with Physics.P2 and I would like the player to stick to the ground (exept if I jump of course).

 

Default behaviour is OK but when there is a bump on the ground and I'm running, the player get an Y-axis momentum so he jumps. It's a nice behavior for a racing game but I don't want it in my platformer :-(

 

Thank you in advance !

 

 

PS: I noticed that the P2 - Platformer Material example it completly broken.

Link to comment
Share on other sites

Yes my ground is made of polygon.

i guess you created this one in physicseditor or something similar...   i'm just asking because i am searching for a way to use polygons created in "tiled" map editor for this...    

 

funny thing.. in my game i would like my player to fall even faster ^^   you could set a custom property "maximum_y_velocity" and check in your update loop if your player falls faster than that - if so fix it to the maximum value... 

Link to comment
Share on other sites

I use PhysicsEditor yes, but I manually type each coordinate in a file (it's actually a JavaScript Array() ), I don't use the export button.

 

About the maximum velocity, that's a nice fix but I would like something cleaner. For the moment, I just modified the gravity. Thank you for your help.

Link to comment
Share on other sites

  • 1 month later...

I'm still working on a solution for this problem myself, my approach is to check the normal vector of the colliding ground shape's contact line and use that for the player body's gravity (I set gravityScale to 0 and handle it with applyForce) and movement vectors. But it's a damn hard problem and it doesn't work correctly yet - it seems that the normal vectors I get from the collision equations sometimes point in the wrong direction when there's a polygon point where I hit the shape :(

 

If anybody know how to do this better, please post!

 

thanks   :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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