# Individual Toggling

Get help using Construct 2

### » Sun Dec 06, 2015 2:02 pm

Hi again!

What I am trying to do now is to make a type of mob toggle left or right at random time intervals. Problem is, when there are multiple mobs (Slimes), all Slimes would change direction at the same time. I've tried using (Pick Random Instance) to solve the selection issue, and then (4 seconds / Slime.Count) so that the time interval between the toggling in slime direction is the same.

It worked for a bit, but now the slimes aren't even changing direction. Is there a more efficient way to do this? Thanks in advance!
B
8
S
2
Posts: 27
Reputation: 610

### » Sun Dec 06, 2015 2:04 pm

Is there a way to determine which "Mob" the slimes are part of?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Sun Dec 06, 2015 2:13 pm

Wait I've got it working through this form of code

It seems the problem stems from before the game has any Slime instances (In this case a Ribbon Pig), so by placing the condition of having at least 1 Slime I avoided that problem!
B
8
S
2
Posts: 27
Reputation: 610

### » Sat Dec 19, 2015 5:38 am

Bump, wanted to see if there was a better way of doing this as random picking is sometimes "biased" and it overpicks the same instance
B
8
S
2
Posts: 27
Reputation: 610

### » Sat Dec 19, 2015 5:45 am

For Each loop, or manually sorting through a counter

but

You can do this:

Every 1 second>>>
Enemyslime coinflip == 0>>
set Enemyslime.Coinflip = random(1, 3)

Enemyslime.coinflip == 1>>>
set toggle to <left>

Enemyslime.coinflip == 2>>>
set toggle to <right>

see if this starts choosing them better.
B
5
S
1
Posts: 68
Reputation: 515

### » Sat Dec 19, 2015 6:17 am

Itenimum1 wrote:For Each loop, or manually sorting through a counter

but

You can do this:

Every 1 second>>>
Enemyslime coinflip == 0>>
set Enemyslime.Coinflip = random(1, 3)

Enemyslime.coinflip == 1>>>
set toggle to <left>

Enemyslime.coinflip == 2>>>
set toggle to <right>

see if this starts choosing them better.

I see! I'll try when I get back, but do I need to put "round" in front of the random(1,3) so it doesn't choose decimals?
B
8
S
2
Posts: 27
Reputation: 610

### » Sat Dec 19, 2015 6:41 am

Nitari wrote:
Itenimum1 wrote:For Each loop, or manually sorting through a counter

but

You can do this:

Every 1 second>>>
Enemyslime coinflip == 0>>
set Enemyslime.Coinflip = random(1, 3)

Enemyslime.coinflip == 1>>>
set toggle to <left>

Enemyslime.coinflip == 2>>>
set toggle to <right>

see if this starts choosing them better.

I see! I'll try when I get back, but do I need to put "round" in front of the random(1,3) so it doesn't choose decimals?

yeah I forgot, floor(random())
B
5
S
1
Posts: 68
Reputation: 515