How do I make enemies follow player

  • Hi , I 'm making a top down shooting game where a player shoots enemies that follow him .I tried to use pathfinding behavior ,but when the player moves all enemies stack above each other while following him, I tried to fix by adding the enemy itself as an obstacle for the pathfinding, but I guess it doesn't work for moving objects.

    Thanks in advance.

    Example of What I am trying to make :

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The beginner's tutorial shows you how to do that https://www.scirra.com/tutorials/37/beg ... onstruct-2

  • "Beginners guide to construct 2 " is not event relevant to the solution I want for my game.

    It only covers the basics, and my issue is when the enemy follows the player, they all overlap on each other. I am looking for a solution to make them gather around the player without any enemy getting on top of another. Hope you got my point and thanks for your help anyway

  • You could try calculating separate points around the player to move to for each enemy so they don't end up following the same path to the same point.

    For example, if you had 4 enemies you'd move them to:

    Enemy 1 = Player.X - 100, Player.Y

    Enemy 2 = Player.X + 100, Player.Y

    Enemy 3 = Player.X, Player.Y - 100

    Enemy 4 = Player.X, Player.Y + 100

    You could also add in some code so that when an Enemy is overlapping another enemy, they both back off a bit in the opposite direction to each other before resuming following the Player.

    Alternatively, you could look at the Boids flocking behaviour

  • Looks like the exact thing I'm looking for, thanks, I'll give it a try as soon as possible

  • If you ever solve this issue, could you post it here or, if you would, even the "How Do I...?" pinned thread. This would be very useful, I'd think.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)