I’m making a top-down game with a simple tilemap for the player to walk around using the keyboard. The player is followed by enemies. Collisions usually work as expected - neither enemies nor the player can pass the walls of the tilemap, nor can they pass through each other. However, when an enemy pushes the player into a wall (or vice versa), no collision is detected and the sprite being pushed goes inside the wall. How can I avoid sprites doing this to each other and breaking the tilemap collision detection?
- Phaser CE 2.10
- Arcade physics. Body is enabled on player and enemies
- Collision detection between player and tilemap layer:
this.game.physics.arcade.collide(this.player, this.layer)The same approach is taken between enemies/layer, enemies/enemies and enemies/player
- Enemy movement:
this.game.physics.arcade.moveToObject(this.enemy, this.player, this.enemy.speed)