Camera rotating around a point instead of the center of the camera?
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:
01 | InputService.InputChanged:Connect( function (input, gameprocessed) |
02 | if input.UserInputType = = Enum.UserInputType.Gamepad 1 then |
03 | if input.KeyCode = = Enum.KeyCode.Thumbstick 2 then |
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 |
09 | if not joystickDebounce then |
10 | joystickDebounce = true |
11 | camera.CFrame = camera.CFrame*CFrame.Angles( 0 ,math.rad( 30 ), 0 ) |
13 | elseif joystickPos.X > 0.5 then |
14 | if not joystickDebounce then |
15 | joystickDebounce = true |
16 | camera.CFrame = camera.CFrame*CFrame.Angles( 0 ,-math.rad( 30 ), 0 ) |
19 | joystickDebounce = false |
Here's an example of how it looks: https://youtu.be/5m_DmPPm9Ac