Hi, i really need some help here, im just working on a game prototype where i must randomly select a location. i got 2 circle in a same position but different radius. let says circle A (the orange circle) and circle B(blue circle).
circle A is bigger than circle B. the problem is, how can i get a position where is inside circle A but outside the B circle
here an example image
You mean, when some other object is inside orange circle but outside blue circle?
public Vector2 GetRandomPositionInside2DTorus( Vector2 center, float innerRadius, float outerRadius )
{
float angle = Random.value * Mathf.PI * 2;
return center + new Vector2( Mathf.Cos( angle ), Mathf.Sin( angle ) ) * Random.Range( innerRadius, outerRadius );
}