titmael Posted May 5, 2014 Share Posted May 5, 2014 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 Link to comment Share on other sites More sharing options...
presidenten Posted May 5, 2014 Share Posted May 5, 2014 You have to call collides(meteorCollisionGroup) on the obstacles bodies as well. Link to comment Share on other sites More sharing options...
titmael Posted May 5, 2014 Author Share Posted May 5, 2014 I updated my first post with :star.body.collides([this.meteor.collisionGroup]);I already do it when creating the star, so you mean I have to re-do it when scalling down my meteor ? Link to comment Share on other sites More sharing options...
presidenten Posted May 6, 2014 Share Posted May 6, 2014 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 More sharing options...
titmael Posted May 6, 2014 Author Share Posted May 6, 2014 Seems to work, thx (the game I'm talking about : http://www.cookingsomegames.com/meteorfall-update/ Link to comment Share on other sites More sharing options...
presidenten Posted May 6, 2014 Share Posted May 6, 2014 No problem :-) Glad I could help! Link to comment Share on other sites More sharing options...
titmael Posted May 7, 2014 Author Share Posted May 7, 2014 Finally unsolved I tried to set collides and collision group of all entities, not working. I'm still getting through some stars ... Link to comment Share on other sites More sharing options...
Recommended Posts