jonteferm Posted March 6, 2017 Report Share Posted March 6, 2017 Hello, I have a problem with handling the collision between sprites. I have a group of enemies and a player sprite. I want none of the sprites to be able to move trough each others. At first I had the enemy body set to immovable and that disabled the player from pushing the enemy around upon collision. However, when I added more enemies to the group, I found that if the enemy bodies is set to immovable = true - they will be able to walk straight trough each others even if they have an internal collision detection (as that is the case between two immovable bodies). So if i set immovable to false - the enemies will appear solid when colliding with each other, but the player is able to push the enemy. What is it that I have not understood? I just want all the sprites solid. Quote Link to comment Share on other sites More sharing options...
samme Posted March 7, 2017 Report Share Posted March 7, 2017 If both objects in a collision are immovable, Phaser isn't allowed to separate them (because immovable), so they will pass through each other. You can try enemies.setAll('body.immovable', true); game.physics.arcade.collide(player, enemies); enemies.setAll('body.immovable', false); game.physics.arcade.collide(enemies); Quote Link to comment Share on other sites More sharing options...
jonteferm Posted March 14, 2017 Author Report Share Posted March 14, 2017 On 2017-03-07 at 5:08 AM, samme said: If both objects in a collision are immovable, Phaser isn't allowed to separate them (because immovable), so they will pass through each other. You can try enemies.setAll('body.immovable', true); game.physics.arcade.collide(player, enemies); enemies.setAll('body.immovable', false); game.physics.arcade.collide(enemies); Thanks! That works fine. Pretty obvious, but I did not think of it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.