Random location but certain distance from object

Get help using Construct 2

Post » Thu Feb 23, 2012 3:24 pm

hi

ive been trying to figure out how to create an object in a random location on the screen but a certain distance away from a central object.

this is what i have for random location. every 3 seconds i create an object at location: x = random(0,800) y = random(0,600)

that works great but i dont want them to appear within a certain area of the screen. this image may help to understand what i mean



the red square is my central object
the blue area represents the no-go zone (distance from object)
the green circles represent the random objects

i need the green circles to appear randomly anywhere on screen but not within a certain distance from the central object ie not inside the blue circle.

is there a formula for this?

thanks
B
3
Posts: 7
Reputation: 339

Post » Thu Feb 23, 2012 3:56 pm

Try creating the object in the middle of the circle, then using the 'Move at angle' action to move it a distance at random(360) degrees.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Fri Feb 24, 2012 10:31 am

Or, make a invisible object, pin it to the player, and check the conditionals:
> Created object is not overlapping the invisible object > spawn;
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

Post » Fri Feb 24, 2012 10:59 am

Ashley's idea is the way to go.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400


Return to How do I....?

Who is online

Users browsing this forum: Evanetot and 17 guests