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

Camera CFrame rotates to the middle?

Asked by
jaschutte 324 Moderation Voter
6 years ago

I've been working on a 3D gui module for a while now, everything is going great except for the rotation. I know how to rotate, position, and scale the part perfectly. but when the GUI is not positioned in the center, the part starts to 'aim' down to the middle. (See image) https://cdn.discordapp.com/attachments/459097889600307211/485785498078412801/Knipsel.PNG Can someone help me to calculate the offset of this? I've tried for many days and I couldn't find it. The code for the CFraming. \/

--abMid is the center of the screengui frame.
local ray = game.Workspace.CurrentCamera:ViewportPointToRay(abMid.X, abMid.Y+36, 0.45)
local camRot = game.Workspace.CurrentCamera.CFrame-game.Workspace.CurrentCamera.CFrame.p
p.CFrame = (camRot + ray.Origin)

Answer this question