# A waiting behind B until A moves again?

Get help using Construct 2

### » Thu Jul 16, 2015 10:19 pm

Hello Community,

I can't figure out a easy solution for this:

5 Enemy's spawns behind each other.
If the Enemy in the Front of the column stops, all enemy's behind him stops moving too.
And if the Enemy in the front is moving again or is dead, the Enemy's behind him starting to move again.

Is there a simple solution for this, or do I have to make like sensor for each Sprite?

Regards
vendara
B
11
S
4
G
1
Posts: 50
Reputation: 1,452

### » Fri Jul 17, 2015 1:55 am

You can try using Pin behavior to make the sprites trail each other, then turning on their own locomotor when the sprite they were pinned to is destroyed.
B
65
S
25
G
19
Posts: 307
Reputation: 14,041

### » Fri Jul 17, 2015 2:09 am

If you need to spawn 5 enemies each time, you could use the For event and have it repeat 5 times.

If all enemies are only moving on a flat ground, it is quite easy, just have all of them use platform behaviour. Use a variable to determine which direction the first enemy is moving in, if it is to the left, set var to 1, to the right set var to 2. Set var to 0 to have them all stop. Than have all the other enemies movement follow the variable.

To select the enemy at the most left or right, you can use the pick function to pick either the one closet to the left or the right edge of the screen. This way once an enemy dies, it will pick the next one closest to it, and you can apply the same var and logic to it.
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

### » Fri Jul 17, 2015 2:57 am

When you say 'behind' do you mean in a line like in situation 'A' or 'B'?

B
10
S
1
Posts: 72
Reputation: 1,019

### » Fri Jul 17, 2015 9:05 am

Here is a Picture of my current stage.

Group A Spawns at beginning,
Group B Spawns like 30 seconds later.

First, no Enemy should walk into another.
So like i said at the beginning, they should all wait behind each other or move together.

If Group A don't move anymore and Group B is catching up, they should also wait until the 1 of Group A moves again.

@Sup with that?
Pin doesnt work, because there will be more than only one Group.

@rekjl
This solution would work, but if 1 of Group A stops moving, Group B who is not next to Group A, will stop moving too.

@GideonG
You can see it now at my screenshot, like Situation B, just with a Space between.
B
11
S
4
G
1
Posts: 50
Reputation: 1,452

### » Fri Jul 17, 2015 12:48 pm

If you want group b to reach a certain position in relation to group a's position, the only way is to calculate that position and have group b move to it. For example, you want group b to always be 50 pixels to the left of group a. Every 0.5 seconds (use less computation power), set Variable1 to groupA.x +/- 50 (depending on whether you want it on the left or right based on group a's movement). GroupB x is not equal Variable1, groupB move to position x = variable1. You could create another variable and use the same process for groupc based on groupb, and etc
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

### » Fri Jul 17, 2015 1:04 pm

I hope it's not wrong to link a game from an other page here.
But this Game is like the perfect example.

You don't have to play long to see what i try to make.
B
11
S
4
G
1
Posts: 50
Reputation: 1,452

### » Fri Jul 17, 2015 1:25 pm

Will your characters also only move in one direction? From right to left? If so, than there is a much simpler solution. Using containers as collision detection.

Create a sprite to be used as collision detection, with the size based on how near you want the groups to be before they stop. Than use a for each event, for each group that is not overlapping that container, move left. This way, all your groups will continue to move left as long as there is not another group with its container there blocking their way.
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

### » Fri Jul 17, 2015 1:40 pm

Well, the character is able to walk trough the little enemys. so they should be able to turn to the right too.
B
11
S
4
G
1
Posts: 50
Reputation: 1,452

### » Fri Jul 17, 2015 4:19 pm

If the character is able to walk through the enemy, than which enemy is going to be the one that moves closest to the character once it passes a few enemies.

Example: This is the order right now

Character - enemy a - enemy b - enemy c
Obviously everyone follows enemy a

Character moves and now the order is this
enemy a - enemy b - enemy c - character
Do they follow the previous order? Enemy a go after character with b and c behind it, or does it change order and c goes after character, b goes after c and etc?

Character moves again and now the order is this
enemy a - enemy b - character - enemy c
Since your character can move past enemies, what happens in this situation?
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Next