How to make dynamic Icons like in Mad City

Hello, how to create dynamic icons on screen like in Mad City?
image

You can get the screen position of an object in 3d space with Camera: WorldToViewportPoint(YourVector3)

Can you give me sample of code, please?

local pos = Camera:WorldToViewportPoint( yourVector3 )

icon.Position = UDim2.fromOffset( pos.X, pos.Y )

You should also set the .AnchorPoint of icon to Vector2.new(.5, .5)


Close, but not awesome

Update after reading the documentation for :WorldToViewportPoint():

local pos, inViewport = Camera:WorldToViewportPoint( yourVector3 )

if inViewport then
    icon.Position = UDim2.fromOffset( pos.X, pos.Y )
else
    icon.Position = UDim.fromScale(-1, -1) -- hidden
end
1 Like

Okay, thanks you for help!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.