jackrugile Posted July 13, 2014 Share Posted July 13, 2014 I was curious if there is a way to increase the rigidity of arcade sprite bodies. At the moment, they seem to overlap quite a bit, and even fall through each other at times. You can see in the gif below (and demo) that a whole row gets lost. Is there any way to completely get rid of this overlapping/fallingissue? If yes, can it be done with arcade physics, or do I need to switch to ninja or p2? Demo of issue here: http://codepen.io/jackrugile/pen/0309643b449e772eba93fc9be3c8e7be/ Tilde 1 Link to comment Share on other sites More sharing options...
lewster32 Posted July 13, 2014 Share Posted July 13, 2014 I don't think Arcade Physics is cut out for this kind of simulation. A few people now have tried to get multiple objects to stack, but run into issues such as this. I'd say try P2 if you need more realistic simulations, or if the above example is the sort of thing you're trying to make (I guess puzzle game mechanics similar to Candy Crush?) a non-physics based approach would work better, using grids and tweens to ensure everything is kept apart. Here's an ugly hack which you probably should not use; you may be able to work this into something though:update: function() { this.physics.arcade.collide( this.dots, this.dots, function(dot) { // discount 'sleep' implementation - this is ugly and not at all consistent // we've not moved much last frame so assume we've come to rest and stop moving entirely if (dot.body.deltaAbsY() < 1) { dot.body.moves = false; } });}, ekiscrim, WombatTurkey and shohan4556 3 Link to comment Share on other sites More sharing options...
jackrugile Posted July 13, 2014 Author Share Posted July 13, 2014 lewster32, Thanks for your reply. I will look into P2 physics in the future if I ever need perfect stacking. You are right about the matching Candy Crush style game, that is what I was going for and thought it would save me some calculations if I just let the pieces fall with gravity rather than move them manually. Before your reply I actually went down that path with grids and tweens and it works great for this situation. Thanks! That is a clever hack, too! Thank you. Link to comment Share on other sites More sharing options...
jackrugile Posted July 13, 2014 Author Share Posted July 13, 2014 Thanks again! Tweens have the advantage of the nice Phaser easings as well lewster32, jdnichollsc, drhayes and 1 other 4 Link to comment Share on other sites More sharing options...
lewster32 Posted July 13, 2014 Share Posted July 13, 2014 That looks absolutely superb! jdnichollsc 1 Link to comment Share on other sites More sharing options...
shohan4556 Posted September 23, 2015 Share Posted September 23, 2015 I was curious if there is a way to increase the rigidity of arcade sprite bodies. At the moment, they seem to overlap quite a bit, and even fall through each other at times. You can see in the gif below (and demo) that a whole row gets lost. Is there any way to completely get rid of this overlapping/fallingissue? If yes, can it be done with arcade physics, or do I need to switch to ninja or p2? Demo of issue here: http://codepen.io/jackrugile/pen/0309643b449e772eba93fc9be3c8e7be/ this link is dead will you please fix it . Link to comment Share on other sites More sharing options...
WombatTurkey Posted June 9, 2016 Share Posted June 9, 2016 I just found a weird solution on accident. If you do something like this inside update game.physics.arcade.collide(LobbyPlayerGroup); game.physics.arcade.collide(LobbyPlayerGroup, LobbyPlayerGroup) (LobbyPlayerGroup reference = this.dots) It fixes the "falling through" issue. If you remove either line, it will break again though. Both collide method lines must be used in that same order. This is probably taxxing on the CPU... but eh, if its for something temporary, don't notice any performance issues it's temp solution for now. (For arcade physics) -- P2 would be ideal as lewst already stated Edit: Wait, it seems like the overlapping is caused by the amount of velocity. So, for a temporary fix for this, just add a new 'game.physics.arcade.collide(LobbyPlayerGroup);' line: For example, if it's starting to overlap/squish your objects, add two collides: game.physics.arcade.collide(LobbyPlayerGroup); game.physics.arcade.collide(LobbyPlayerGroup); --And if you increase velocity again, and it collides, add another, and so on. This does work but as I said, CPU is getting hammered I think, so I wouldn't recommend... this but I think it's kind of a funny solution Link to comment Share on other sites More sharing options...
totenkreuz Posted July 29, 2016 Share Posted July 29, 2016 I'm recently encountering a similar problem! I have to use physics because it is easier for me to add velocity to the blocks! Did anyone manage to recreate the same scenario using P2 Physics? Setting mine to P2 seems to make it act weird, pieces scattering all over the place! Link to comment Share on other sites More sharing options...
Recommended Posts