# How do I spawn at a distance around a circle

Get help using Construct 2

### » Sun May 25, 2014 10:57 pm

Hey!

im trying to figure out a formula on how to spawn objects around a circle. i need it to be random X,Y but at a fixed interval in distance.

so i want the red sprites to only spawn inside in the grey band. any ideas?

PS. the grey band is not an actual sprite, only a visual example of the formula im looking for.
B
8
S
1
Posts: 25
Reputation: 1,140

### » Mon May 26, 2014 12:37 am

You may generate random X,Y coordinates and check whether they are inside an area or not. For instance, you can use the "distance" function and it should be between 2 values. Keep generating coordinates until they are in =)
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

### » Mon May 26, 2014 12:54 am

hmm ye that might work, thanks! i was trying to use a cos/sin but math > me =)
B
8
S
1
Posts: 25
Reputation: 1,140

### » Mon May 26, 2014 1:23 am

tried your solution but i think i solved it another way:

created object at circle.x, circle.y
move object random(500,600) at angle random(0,360)

repeat as many times as i need... did kind of work.
B
8
S
1
Posts: 25
Reputation: 1,140

### » Mon May 26, 2014 10:20 pm

Great! It is nice that there are many ways to achieve a goal! =)
B
24
S
4
G
1
Posts: 177
Reputation: 1,827