pretty much whats in the title, im trying to track some car wheels inside a viewport so that i can put a nice little ui over them but the positions returned from worldtoviewportpoint arent really correct.
RunService.Heartbeat:Connect(function()
for _, v in pairs(Wheels:GetChildren()) do
if table.find(WheelNames, v.Name) then
local Point = Camera:WorldToViewportPoint(v.Position)
--print("Wheel: ", v.Name, "Position: ", Point)
if not ClonedFrames[v.Name] then
local Frame = WheelFrame:Clone()
Frame.Visible = true
Frame.Name = v.Name
Frame.Parent = Viewport
ClonedFrames[v.Name] = Frame
end
local ScaleX = Point.X / Camera.ViewportSize.X
local ScaleY = Point.Y / Camera.ViewportSize.Y
local ClonedFrame = ClonedFrames[v.Name]
ClonedFrame.Position = UDim2.fromScale(ScaleX, ScaleY)
end
end
end)
im pretty new to this tracking 3d positions into 2d positions stuff, so im not the most knowledgeable about this. been scratching my head a lot with it