# How do I make enemies follow player

Get help using Construct 2

### » Sat Aug 23, 2014 12:09 pm

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.

Example of What I am trying to make :
B
25
S
3
G
1
Posts: 67
Reputation: 2,991

### » Sat Aug 23, 2014 1:41 pm

The beginner's tutorial shows you how to do that https://www.scirra.com/tutorials/37/beg ... onstruct-2
Phase 1: Collect Underpants.
Phase 2: ????
Phase 3: Profit!
B
16
S
5
G
4
Posts: 106
Reputation: 2,450

### » Sun Aug 24, 2014 2:37 pm

"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
B
25
S
3
G
1
Posts: 67
Reputation: 2,991

### » Sun Aug 24, 2014 2:54 pm

@daoudsami

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
Find all the Construct 2 games that were on Steam Greenlight here
B
39
S
11
G
7
Posts: 509
Reputation: 7,272

### » Sun Aug 24, 2014 5:50 pm

Looks like the exact thing I'm looking for, thanks, I'll give it a try as soon as possible
B
25
S
3
G
1
Posts: 67
Reputation: 2,991

### » Sat Sep 13, 2014 11:14 am

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.
B
13
S
3
Posts: 17
Reputation: 984