How do I achieve this dynamic CFrame Orientation?
I'm trying to make a floating object part
in front of the player using the camera's CFrame. Note: I cannot only use an offset from the camera, because I want the floating object to appear flat and as if it were facing the camera directly, this cannot be achieved without using the LookAt
parameter of CFrame.new()
Code:
01 | local RunService = game:GetService( "RunService" ) |
02 | local LocalPlayer = game:GetService( "Players" ).LocalPlayer |
03 | local myCamera = workspace.CurrentCamera |
05 | local part = Instance.new( "Part" ) |
07 | part.CanCollide = false |
08 | part.Parent = workspace |
09 | RunService.RenderStepped:Connect( function () |
10 | local p = myCamera.CFrame.Position+(myCamera.CFrame.LookVector* 10 )-(myCamera.CFrame.RightVector* 8 ) |
11 | part.CFrame = CFrame.new(p,myCamera.CFrame.Position) |
How can I stop the object from rotating in the manner showed in this GIF ?