I’ve searched all over the internet for a possible solution, the closest I came to it working is using the code from here. The problem with this though, is that the camera doesn’t stay over the shoulder when you walk into anchored parts:
I have tried many scripts and methods suggested on previous posts, none of which worked. I’d appreciate if anyone could let me know of a method that could make this work. Polyguns is the perfect example of what kind of camera I’m looking for. So if anyone has any ideas of how they do it, please let me know, thank you.
If you want the camera to “not go through walls”, you can try raycasting from the head position to the position you want the camera to be. You can set the camera’s position to the position that the raycast returns.
How do I force the character to stay in position with the camera? At the moment it seems like the camera is just set once to the position it should be in, but doesn’t force it, since you can change the angle when the character isn’t able to rotate. The camera should be forcing the character to turn together with it, like it does with shift lock.
If I am understanding what you mean correctly, and you want the character to always be in the same rotation as the camera, then you can set the HumanoidRootPart’s CFrame to it’s position with the camera’s rotation. Remember to turn off the Humanoid’s AutoRotate option.
Example code: HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position,HumanoidRootPart.Position+Camera.CFrame.lookVector*Vector3.new(1,0,1))
There is a simple way to enable mouse lock.
Inside game.StarterPlayer.StarterPlayerScripts there should be a module script named PlayerModule.
(if you don’t already have the module there, then you need to playtest in the studio to get a copy so that you can edit it, since it is automatically added if there isn’t one detected).
After that go into PlayerModule.CameraModule and put self.activeCameraController:SetIsMouseLocked(true) into the bottom of the CameraModule:Update() function.
All that is left is to change the CameraOffset the character’s Humanoid to something like Vector3.new(2,1,0), and then change the mouse icon.
You should also disable shift lock as it can interfere with this mouse lock.
I hope this helps.