I’m working on a personal project with crosshairs, and I haven’t found a good way to get a random position in between the crosshair based in a circle.
Based on what I’ve read, I believe I got all of the math down correctly.
Here is my function:
function Crosshair:getRandomPointInsideCrosshair(offset)
local r = offset * math.sqrt(math.random())
local theta = math.random() * 2 * math.pi
local x = r * math.cos(theta)
local y = r * math.sin(theta)
return x,y
end
The “offset
” argument that is given with the function is the crosshair position (in offset) from the center of the screen.
Here is an example of what’s happening, not sure what is happening to cause this so I decided to come to the dev forum to ask:
Any response is highly appreciated if you could help!
And before anyone says anything, yes I have looked at other topics, and yes I have done my fair share of research.