Jump to content

How to have a static-like body in Phaser P2 that still collides with world bounds?


Recommended Posts


I recently converted a game I was making into P2 physics, only to find none of my objects are colliding with the world boundaries. Since I need the player objects to collide with the world boundaries, I attempted to create a collision group:


    var playerCollideGroup = this.physics.p2.createCollisionGroup();

<define all player objects details>


However my player objects are still not colliding with world boundaries. Is there something I am missing?



So I reviewed the code I had been using based in this thread; it appears that making my player body static (this.player.body.static=true;)  was the issue. However as indicated by the CodePen examples in that thread I reliant on the body to be static for proper rotation of objects around the player. What can I do to have the player still collide with world bounds while still remaining static-like in movement?

Link to comment
Share on other sites

Hi you could try to set the mass of your object to a very high number (more mass--> tougher to move an object). In the codepen examples it would be something like:


But it might be that you have to apply more force/ add higher velocities to move your player around in the world, so you have to take that into account.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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