Jump to content

P2 collisionGroup no collisions


titmael
 Share

Recommended Posts

Hi,

 

With P2, I have in my game a meteor and stars. I have 2 groups : meteorCollisionGroup and starsCollisionGroup.

 

When I create my meteor I do :

this.sprite.body.collides(this.starsCollisionGroup, this.hitObstacle, this);

When I pop a star, I do 

star.body.setCollisionGroup(this.starsCollisionGroup);star.body.collides([this.meteor.collisionGroup]);

When my meteor hit a star, I scale it down (and when it's a bonus (another group) I scale it up) :

this.sprite.scale.x = this.sprite.scale.x * 0.9;this.sprite.scale.y = this.sprite.scale.y * 0.9;this.sprite.body.setCollisionGroup(this.collisionGroup);

Then my meteor sometime overlap a star without hitting it ... and I have no clue why I have this behavior. When I activate debug on bodies, nothing's wrong.

 

Looks like stars overlaped have already poped when scaling down my meteor. But lots of already poped stars do hit my meteor.

 

If you have any idea, you are welcome  :P

Link to comment
Share on other sites

I think its like this. If you just scale the sprite, then you wont have a problem. But, if you change the P2 physics body size, then you have to reset setCollisionGroup(entityCollisiongroup) and collides(entityCollisiongroup) after a resize. 

I do not have to set callback on collsions between collisiongroups again though. Only reset the collisiongroup and that I want it to collide with itself.

Link to comment
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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