I have a basic physic grab system, however the one more thing I want to add is the ability to rotate object while holding it. (Think garry’s mod phys gun)
However I have problem with rotating the object, because I want to use mouse movement while the mouse sensitivity is set to 0, so getting mouse delta doesn’t work with this, using input position seem to just also give me one value only, weirdly. I’ve tried searching the forums but most are solved with getting mouse delta, which doesn’t work with what I’m doing.
Here’s me using mouse delta and setting the mouse sensitivity to really low value and multiplying the movement delta
The problem with this approach is that for the first frame the rotation will jump before moving at the sped I want.
And also this just seem very hacky so I’m trying to look for a better approach.
I’ve already tried using user input service but keep getting only one value from the position
Under your PlayerScripts, you’ll find PlayerScriptsLoader and PlayerModule which roblox naturally injects in. This system controls your movement and camera on all platforms.
Copy it and paste it into StarterPlayerScripts. You now override roblox’s script injection with your own version of their script as long as the same name is used.
You can now modify their camera control system.
In BaseCamera, there is a function detailing camera rotation detection, “CalculateNewLookCFrameFromArg”, use this to figure out which module(s) are controlling the camera.
In this case I found the relevant module in ClassicCamera, but you will find it in other camera modes if you plan to use a different mode (such as VR or Orbital).
Scrolling a bit towards the top you’ll find a section where the code is getting the mouse input to feed to the camera rotation:
-- assumption: game.UserInputService.MouseDeltaSensitivity = 1
local rotateInput = CameraInput.getRotation()
print(rotateInput)
rotateInput = Vector2.new(0,0) -- set rotateInput to 0,0 to lock the camera rotation
-- you can still read the original rotateInput to get the rotational value
You now can “lock” the camera in place without setting the mouse sensitivity to 0 while also receiving rotational input from the user.