ZoomBox Posted May 2, 2014 Share Posted May 2, 2014 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 More sharing options...
valueerror Posted May 2, 2014 Share Posted May 2, 2014 i guess if your gravity is high enough (1200 for example) and your restitution is 0 your player should allways stay on the ground.. what do you mean by "bump on the ground" ? are you using a polygon ground somehow? Link to comment Share on other sites More sharing options...
ZoomBox Posted May 2, 2014 Author Share Posted May 2, 2014 Haha, thank you. That's actually a quite good solution. I'm wondering if there is no other solution (because now the player falls too quickly). Yes my ground is made of polygon. Link to comment Share on other sites More sharing options...
valueerror Posted May 2, 2014 Share Posted May 2, 2014 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 More sharing options...
ZoomBox Posted May 5, 2014 Author Share Posted May 5, 2014 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 More sharing options...
wayfinder Posted June 11, 2014 Share Posted June 11, 2014 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 More sharing options...
Recommended Posts