GooodWin67 Posted January 17, 2018 Share Posted January 17, 2018 hi all I did this (use arrow) Everything works, but if there is a barrier, the enemy can not get around it. How can I fix this? Link to comment Share on other sites More sharing options...
head Posted January 18, 2018 Share Posted January 18, 2018 The enemy behaves exactly as you told it to =) In this code: if (!checkOverlap(player, enemy)) { if (enemy.body.x < player.body.x - 10) { enemy.body.velocity.x = 30; //enemy.body.velocity.y = 0; } ... }Th The thing is that the tree is just big enough. So when enemy is trying to converge with the player +/- 10 pixels is just not enough to come around the tree. Hint: you won't solve this using some constant numbers. You either need additional rules (like gravity and jumping) or you need some kind of pathfinding. Link to comment Share on other sites More sharing options...
Recommended Posts