# How to create a random spawn on a circle ?

From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game          • I mean not in the circle but ON the circle.

I know that to create a random spawn in a circle around a player of radius 100 we can use for example:

X = J1.X + 100 * cos (random (360))

Y = J1.Y + 100 * sin (random (360))

I imagine that there must be a simple solution to my problem.

#### Tagged:

• You mean on the circle line?

Set a = random(360)

X = center.X + 100 * cos (a)

Y = center.Y + 100 * sin (a)

• Thank you very much that was exactly what i wanted. :)

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• I keep reading it over and over, and the two looks exactly the same. What makes J1.X different to center.x? Or does making random(360) a variable make a difference?

I've been trying to figure out how to created a random spawn IN a circle, and this is the closest I've gotten, and I still can't figure it out.

• random (360) for x is most likely different than random(360) for y

They need to be the same angle even if its a random one.

• random (360) for x is most likely different than random(360) for y

They need to be the same angle even if its a random one.

Yup, just figured this out from a post of yours from 2 years ago! Thanks for the reply, good to see you again!

• The 100 here is the radius, so if you randomize the radius also, the point will be inside the circle (as long as you reduce the max radius by the 'radius' of the object you are spawning).

• 7 posts