Mathematical Problem that I can't get around


I’ve been trying to achieve something that is out of my reach, as I don’t know how to approach this problem.

You spawn with a huge circle, that is the range where you can create the orange circle. However, I want to make a system where when you click outside of your range, the organge circle still is inside your range using mathematics. This is what I’m trying to achieve.

Example 1 is when you click outside of your range, the oragne circle gets created outside of your range.


Should turn into this
Example 2, the orange circle gets automatically put inside your range as seen in the pictures.

If you know how I can go around it, it would help me a lot!

1 Like
local big_circle_radius = 9
local small_circle_position =
local small_circle_radius = 3
local center =

if (center - small_circle_position).Magnitude > (big_circle_radius - small_circle_radius * 0.5) then
    small_circle_position = small_circle_position.Unit * (big_circle_radius - small_circle_radius * 0.5)
1 Like