pandavigoureux29 Posted April 10, 2014 Share Posted April 10, 2014 Hi all, I have some issues with CollisionGroups ( I used to use them for ImpactEvents and am starting to wonder if there are not made just for that) I'll try to make it short and clear : Let's take two collision groups :var playerGroup = game.physics.p2.createCollisionGroup();var groundGroup = game.physics.p2.createCollisionGroup();Now let's take two sprites (assume they are created and physics is enabled) and set their collision groups:player.body.setCollisionGroup(playerGroup);ground.body.setCollisionGroup(groundGroup);With that if I want to enable collisions between these two sprites, I have to do this :player.body.collides(groundGroup);ground.body.collides(playerGroup);So here is the issue : if I put just one of these line, nothing happens.Isn't it enough to tell one body or the other to collide? It seems redundant to me. If that's the way it is, I'll deal with it, but I want to be sure I'm not making any mistake here Thanks Link to comment Share on other sites More sharing options...
JP91 Posted April 10, 2014 Share Posted April 10, 2014 By this way you can control you want to collide, and collision mask seems like a very powerful tool and widely used in physics engines.. Link to comment Share on other sites More sharing options...
JP91 Posted April 10, 2014 Share Posted April 10, 2014 .. Link to comment Share on other sites More sharing options...
pandavigoureux29 Posted April 10, 2014 Author Share Posted April 10, 2014 I totally see the point of collision mask , but, in my example, I don't see how the player can collide with ground without ground colliding with the player.It just seems to me I am writing two lines that do the same thing. Link to comment Share on other sites More sharing options...
valueerror Posted April 11, 2014 Share Posted April 11, 2014 I totally see the point of collision mask , but, in my example, I don't see how the player can collide with ground without ground colliding with the player.It just seems to me I am writing two lines that do the same thing.my thoughts exactly... but it seems to be that way so i deal with it... you could spare a lot of lines if you dont use this at all and instead work with onBeginContact() Link to comment Share on other sites More sharing options...
pandavigoureux29 Posted April 11, 2014 Author Share Posted April 11, 2014 You mean the body.onBeginContact ? I already use it but this is just a Phaser.Signal. It doesn't make anything collide, for what I know. If I'm mistaken I'll be happy to know it, though Link to comment Share on other sites More sharing options...
valueerror Posted April 11, 2014 Share Posted April 11, 2014 hmm... but if you don't assign collisiongroups at all in p2 everything collides with everything... i thought that onBeginContact should work in this scenario to trigger an event when something collides with something else... Link to comment Share on other sites More sharing options...
pandavigoureux29 Posted April 12, 2014 Author Share Posted April 12, 2014 Okay, I didn't try without collision groups as I want to filter my collision for better performance. Link to comment Share on other sites More sharing options...
valueerror Posted April 12, 2014 Share Posted April 12, 2014 interesting.. what you say makes sense to me but according to rich the impactEvents needed for collisiongroups, groupcallbacks, ect. are responsible for low performance and onBeginContact would be better.. Link to comment Share on other sites More sharing options...
pandavigoureux29 Posted April 12, 2014 Author Share Posted April 12, 2014 Actually I'm using collision groups to let p2 manage the collisions. I dont do the setImpactEvent( true ) and use onBeginContact instead only for bodies I choose.I believe that not enabling the impact events will prevent the performance issues. Link to comment Share on other sites More sharing options...
valueerror Posted April 12, 2014 Share Posted April 12, 2014 so impact events are for the groupcallbacks (or bodycallbacks etc.) only.. hey thx.. now i can think about rewriting some code of mine Link to comment Share on other sites More sharing options...
pandavigoureux29 Posted April 12, 2014 Author Share Posted April 12, 2014 Yes, at least that's what I understood from the doc :http://docs.phaser.io/Phaser.Physics.P2.html#setImpactEvents Link to comment Share on other sites More sharing options...
Recommended Posts