[P2] Moving a Group doesn't move bodies of its children

Recommended Posts

Hi all,


I've come across a problem with groups and P2 bodies.



Basically, I have a group, to which I add a Sprite with a P2.Body.


So when I move my group, the sprite is actually moving with it, but its body does not budge an inch.


Is there a fix to this? 



Share this post

Link to post
Share on other sites

What you have happening is that p2 is really a separate system than phaser. Once it's connected to your sprite it becomes the puppet master and phaser handles the front end. So adjusting phaser's group position is only adjusting the way it is rendered, but p2 has no clue. Reading the p2 docs ( ) there aren't any group type objects so trying to integrate that directly would be tricky. I would probably write a function that adjusts the p2 bodies directly instead of adjusting the group position.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.