Hey! So I know I can use WorldToScreenPoint to check whether or not a Part is visible, and the position of it in 2D, but how would I manage to know if that Part is inside a circle on my screen?
Image:
https://i.gyazo.com/1e6404851183b4564322c35cfcf5ec8c.png
I don't want full script, I just need the calculation.
Try using .magnitude. Take the position of the center of the circle and the position of the part and see if the magnitude is equal to or less than a certain number. Ex:
01 | local Part = game.Workspace.Part |
02 | local MiddleOfCircle = game.Workspace.Circle.Position |
03 | local Radius = 15 -- Just an example |
04 |
05 | Part.Changed:Connect( function () |
06 | local Magnitude = (MiddleOfCircle - Part.Position).Magnitude |
07 | if Magnitude < = Radius then |
08 | Part.Transparency = 0 |
09 | else |
10 | Part.Transparency = 1 |
11 | end |
12 | end ) |