Camera lock without first person

What im trying to do is make an offset third person camera. I attempted to do this by setting StarterPlayer.CameraMode to LockFirstPerson, but as this locks the camera to the player, it unfortunately also forces the camera to be in first person. Is there any other way of having the player and camera follow the player’s mouse, or do i have to go through a massive amount of setting camera cframes to accomplish this?

1 Like

You can actually change the CameraMaxZoomDistance in StarterPlayers to 0.5 as another way to do this.

Here is an article: Player | Documentation - Roblox Creator Hub

edit: you can change it back to 400 whenever you need it off of First Person

edit2: Sorry I Misread your topic, here is a post that can help you with this: Need help with camera

And here is an article to go with it: UserInputService | Documentation - Roblox Creator Hub

I went through a lot of turmoil some months ago trying to do just this. If I understand it right, you’re looking for a MouseLock style camera?

There’s actually a way to force a player into MouseLock via editing the default PlayerModule.

If you go into a Play Solo, Players > Your Player > PlayerScripts, you can find a ModuleScript called PlayerModule. Copy that.

Then, end the play solo and paste the module into StarterPlayerScripts. This will replace the default PlayerModule with the one you just copied.

Inside of the PlayerModule there are many other modules. One of them deals with the Camera. If you go inside of this Camera module and Shift+F to search, you should be able to find the method where mouseLock is enabled.

For my purposes, I simply rigged up a new method inside of the CameraModule in which I set the mouseLock manually.

The method I made uses the same code that the module uses elsewhere for when a player chooses to go into MouseLock mode:

function CameraModule:LockMouse()
	if self.activeCameraController then
		local mouseLockOffset = self.activeMouseLockController:GetMouseLockOffset()
		self.activeCameraController:SetIsMouseLocked(true)
		self.activeCameraController:SetMouseLockOffset(mouseLockOffset*3)
	end
 end

Then, whenever you want the camera to be set, in a local script or module somewhere, just call the method. For my game, I call it inside of a RenderStepped function, but to be honest I’m not sure if that’s necessary or not. I just know it works.

Side note, I multiplied mouseLockOffset by 3 just to make the character appear slightly further off screen.

Hope this helps

7 Likes

can you remind me how to call a method from the module? sorry, i dont work with module scripts much

Sure!

You’d just need to require the CameraModule in whatever script you intend to call it from, then whatever you named the variable as, use :LockMouse() on.

For example:

local camModule = require(CameraModule)
camModule:LockMouse()
2 Likes

Thank you so much! there is just one more problem. I have the camera offset from the head a little bit, and i believe that is what is giving the camera this wierd skipping effect. (it might give my players a brainurism)

https://i.gyazo.com/5e6eacf3c02bcf52ae32dfb3c6939039.mp4

is there any way to fix this?

1 Like

Could be that. May also just be your mouse sensitivity is too high.

1 Like