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

Camera rotating around a point instead of the center of the camera?

Asked by 4 years ago

Hi, I am creating a VR game, and making a function to "snap" the camera to a certain rotation. For some reason it's rotating around a point, making the camera go in a very weird way. Here's the code I currently have:

01InputService.InputChanged:Connect(function(input, gameprocessed)
02    if input.UserInputType == Enum.UserInputType.Gamepad1 then
03        if input.KeyCode == Enum.KeyCode.Thumbstick2 then -- Rotating (right controller)
04            local joystickPos = input.Position
05            local camera = game.Workspace.CurrentCamera
06            camera.CameraType = Enum.CameraType.Scriptable
07            local rightControllerCFrame = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
08            if joystickPos.X < -0.5 then -- left
09                if not joystickDebounce then
10                    joystickDebounce = true
11                    camera.CFrame = camera.CFrame*CFrame.Angles(0,math.rad(30),0)
12                end
13            elseif joystickPos.X > 0.5 then -- right
14                if not joystickDebounce then
15                    joystickDebounce = true
View all 23 lines...

Here's an example of how it looks: https://youtu.be/5m_DmPPm9Ac

Answer this question