Jump to content

tracking the enemy


GooodWin67
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...