Basically the title, how could I do this?
You should calculate rotation angles for the Y and X axes, apply them to the hinges, then you connect it to the mouse event.
function = update(mouse)
local mouse_position = mouse.Hit.Position
local rotationY = math.atan2(mouse_position.X - hingeY.Position.X, 1)
local rotationX = math.atan2(mouse_position.Y - hingeX.Position.Y, 1)
hingeY.CFrame = CFrame.fromEulerAnglesYXZ(0, rotationY, 0)
hingeX.CFrame = CFrame.fromEulerAnglesYXZ(rotationX, 0, 0)
end
game:GetService("UserInputService").InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
update(input)
end
end)
2 Likes
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.