I’ve got a script that sets a parts position infront of the camera ever frame, and that works fine, but I have a way of using ScreenPointToRay to get the spot on screen in which I want to put the part. The problem with this is that I cannot get the UI to always be facing the camera. This is my code, and a gif of the problem.
local function RenderStepped()
local ScreenRay = Camera:ScreenPointToRay(15, Camera.ViewportSize.Y -15, 7)
UIPart:PivotTo(CFrame.lookAt(ScreenRay.Origin, ScreenRay.Direction))
end
GIF:
(The part should appear stationary, but instead it rotates. The position itself seems fine, it’s just the rotation.)
Hi, thanks for the reply. This is what I originally did, 100% worked, the problem comes when I try to position the part somewhere that isn’t the centre of the screen, that’s why I used ScreenPointToRay to get a spot to place the part on that part of the screen. There may be some alternative to ScreenPointToRay that I’m not aware of though. The part needs to be in about the same spot on all resolutions, which is why I used ScreenPointToRay as well.
Thanks, that worked for the most part, but the only problem is that it doesn’t rotate with the camera. I tried doing this: CFrame.new(CFrame.lookAt(ScreenRay.Origin, ScreenRay.Direction).Position) * CFrame.Angles(math.rad(-5), math.rad(5), math.rad(0)) but got this result: