Keenic Posted April 4, 2016 Share Posted April 4, 2016 Hi, I'm creating a game where i have to build a tower. Whenever i drop a box all boxes sometimes bounce a little. I set the block body.bounce = 0 Here is a video http://screencast.com/t/R7hhnlbq Is there any way to disable that feature? Link to comment Share on other sites More sharing options...
Wasyl Posted April 8, 2016 Share Posted April 8, 2016 I have similar problem. Any ideas? Link to comment Share on other sites More sharing options...
WombatTurkey Posted April 8, 2016 Share Posted April 8, 2016 I barely notice it... but it's there. Maybe you can try setting the body's mass to a high value? Link to comment Share on other sites More sharing options...
Keenic Posted April 8, 2016 Author Share Posted April 8, 2016 There is no body mass in ninja engine. Additionally a blocks flatten when there are stack. Link to comment Share on other sites More sharing options...
Keenic Posted April 19, 2016 Author Share Posted April 19, 2016 Any ideas how can i prevent that effects? Link to comment Share on other sites More sharing options...
drhayes Posted April 19, 2016 Share Posted April 19, 2016 I'm *pretty* sure what you're seeing is Ninja physics trying to separate the boxes and the platform. They overlap a little bit and then they get separated. Arcade physics has the same problems. AFAIK there's not a way to fix that besides using a different physics engine like P2. I think you can try calling the collision handlers multiple times in an update to give things a chance to settle. Maybe try that first? Link to comment Share on other sites More sharing options...
Keenic Posted April 20, 2016 Author Share Posted April 20, 2016 I have this in update // Blocks and platforms collision this.game.physics.ninja.collide(this.game.blocks, this.game.platforms, this.blockCollision.bind(this)); // Blocks collision for (let i = 0; i < this.game.blocks.children.length; i++){ for (let j = 0; j < this.game.blocks.children.length; j++){ if (i == j) continue; this.game.physics.ninja.collide(this.game.blocks.children[i], this.game.blocks.children[j], this.blockCollision.bind(this)); } } Well, if its a physics bug I think its ok. Thanks for answer. Link to comment Share on other sites More sharing options...
drhayes Posted April 20, 2016 Share Posted April 20, 2016 You don't need to iterate the group like that. You can just pass the group in like this: this.game.physics.ninja.collide(this.game.blocks, this.game.blocks, this.blockCollision, null, this); Also, you don't want to bind your this.blockCollision method multiple times in update. Each time you do that it'll make a new function. That puts a lot of pressure on the garbage collector and will probably make your game stutter. The fifth parameter of ninja.collide is the callbackContext; in other words, it's the "this" value for your callback. This will have the same effect as calling bind but should run better. Link to comment Share on other sites More sharing options...
Recommended Posts