Jump to content

Expect collision with ground but players fall through


NumberOneRobot
 Share

Recommended Posts

Hello,

 

I'm trying to make a set of platforms in my game using the p2 physics engine. I'm using p2 on the backend, and phaser for the frontend. I have set up four platforms arranged in a column like this:

 

----------

 

----------

       x

----------

 

----------

 

Note: The 'x' marks the center of the world.

 

The issues I'm having is that the collisions work in one direction but not the other, for each of the four platforms. In one direction, the player correctly collides with the platform. In the other, the character gains a huge burst of speed and is shot through the platform. On the two bottom platforms, the player can fall down through the platform and get the speed burst, but not move upward through the platform. The top two platforms have the opposite issue, they shoot you upwards if you collide with them when jumping upwards, but you can properly stand on them.

 

I think part of the issue might be where I've set the center of the map and the way I implemented the platforms. I made the map and the ground as a single physics body (maybe not a best practice but I'm really not sure), and the center of the map is what I marked as the position of the body. Each of the platforms is a polygon, and the body is marked as static.

 

The reason I think the issue may be the body's position, is because when I move any of the platforms to the opposite side of the center, the effect of colliding with them matches the other platforms on that side of the center point. I have no idea what may be causing this, as I can't even find the p2 collision code.

 

Any suggestions?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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