Hello, Ive been creating a dragging system for a project of mine, and i can figure out how to get the parts to face the camera. For reference, I’m trying to achieve what Defaultio has in Lumber Tycoon 2.
for reference: https://streamable.com/ixwr5g
I have been able to get the delta of the camera position between frames, so that’s a plus. Before you ask, no, i cannot just set it to the camera’s orientation because I plan on adding more rotation features which that will not allow. Plus it would wierdly rotate the part if its oriented away from the camera. I feel like im on the right track because the part seems like its staying still in world space, but i cant get it to face the camera.
Ive been trying a bunch of guess/check and just throwing variables around, negating them, inversing things, and i cant seem to get any results. Heres what im currently getting:
and here’s what im currently doing:
(binded to renderstepped)
local OldX, OldY, OldZ = (lastCameraCFrame or Camera.CFrame):ToEulerAnglesXYZ()
local NewX, NewY, NewZ = Camera.CFrame:ToEulerAnglesXYZ()
local AddedX, AddedY, AddedZ = OldX - NewX, OldY - NewY, OldZ - NewZ
local CurrentX, CurrentY, CurrentZ = draggingOre.CFrame:ToEulerAnglesXYZ()
local X = CurrentX + AddedX
local Y = CurrentY + AddedY
local Z = CurrentZ + AddedZ
local RotCFrame = CFrame.fromEulerAnglesXYZ(X, Y, Z)
draggingBodyGyro.CFrame = RotCFrame
Any help would be appreciated! I’m all out of ideas.