# How do I detect unit within certain radius of another unit?

Get help using Construct 2

### » Tue Mar 10, 2015 10:31 pm

hello,
need help to set conditions to detect every unit within certain radius or distnce of another unit?

any tips?

tnx!
Last edited by irina on Wed Mar 11, 2015 1:21 pm, edited 1 time in total.
B
38
S
17
G
3
Posts: 872
Reputation: 6,905

### » Tue Mar 10, 2015 10:41 pm

B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

### » Tue Mar 10, 2015 10:51 pm

Spawn a circle sprite and pick everything that overlaps it.
B
53
S
16
G
9
Posts: 1,098
Reputation: 11,282

### » Wed Mar 11, 2015 1:21 pm

@newt
thanks but i need some math. equation solution.

@spongehammer
thats plan B if noone has idea how to do it by some math equation....

anyone has some math sloution?
B
38
S
17
G
3
Posts: 872
Reputation: 6,905

### » Wed Mar 11, 2015 1:57 pm

Well strictly speaking that is using an equation, its just that you dont see it.
B
53
S
16
G
9
Posts: 1,098
Reputation: 11,282

### » Wed Mar 11, 2015 2:01 pm

You can use for each, and distance(), but its not very efficient.
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

### » Wed Mar 11, 2015 2:29 pm

Pick by comparison, distance() < range
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143