Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Check if Part is on a part of the screen?

Asked by 5 years ago
Edited 5 years ago

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.

0
link is said to be not valid aandmprogameing 52 — 5y
0
Maybe you could make a GUIs position on the part and then see if the GUIs in the circle RealTinCan 217 — 5y

1 answer

Log in to vote
0
Answered by
Knqe 23
5 years ago

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:

local Part = game.Workspace.Part
local MiddleOfCircle = game.Workspace.Circle.Position
local Radius = 15 -- Just an example

Part.Changed:Connect(function()
local Magnitude = (MiddleOfCircle - Part.Position).Magnitude
if Magnitude <= Radius then
Part.Transparency = 0
else
Part.Transparency = 1
end
end)
Ad

Answer this question