Jump to content

Player velocity changing while the ground moves under its feets


ZoomBox
 Share

Recommended Posts

Hello !

 

I have a problem, I don't know if this behavior is the one expected (physics.p2).

Here it is:

 

I have a player with doesn't move on the screen, I make platforms come to the player with no friction so the player still doen't move and slide on the platforms.

The problem is that the player velocity is taking bigger and bigger values, it's increasing insanly even if the player doen't move.

 

If I set the player velocity to 0 each update, it works the same way... I just don't understand why is it increasing ?

 

It's causing me problems in the devloppement of my game :-(

Thanks :-)

Link to comment
Share on other sites

These are just suggestions - I haven't yet used the P2 physics. I suspect if you remove all friction from a platform, then the player's velocity will increase as the platform offers no resistance and even tiny movements will send the player flying off. Does leaving the friction at default and setting body.kinematic = false on the platform help at all? This is of course assuming you're not moving the platforms with P2 physics, in which case things will be complicated. Continuously colliding bodies in any physics system is a subtle and often difficult problem to solve.

Link to comment
Share on other sites

Hey, thank for your help.

Actually, I can neither set body.kinematic = false nor leaving the default friction.

It will be too much calculation because my aim is to keep the player at the same X position. So leaving the default friction will make him go back (stuck to the platform) and then I should make the player go forward to keep him centered.

 

It's like having two unnecesarry opposed forces.

 

Actually I found a solution: I create an intermediate variable, I do my calculation on it and I set the player.velocity with my variable.

But it's still confusing (especially since have a velocity of 9*10-14 do exactly the same as having a 0 velocity).

 

Thank you man.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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