CameraService - A New Camera for a New Roblox

When I have the time, I’ll look into it. I currently am prioritizing other personal projects and things at the moment, so it’ll take some time and patience for that.

1 Like

This is just what I needed, you really did an awesome job with the presets, thank you for sharing such a high quality resource, take ur 100th like, you deserve more!

Hello, I cant move my camera while im in first person. do you know why?

Any output errors? It works fine for me.

No errors

and also another issue, is the mouse supposed to stay in the center in ShiftLock mode? (also camera doesnt move in shiftlock mode either)

camera only moves in thirdpersonmode for me

Can you send over the code you used to implement the system?

Nice service it is tremendously useful!, but you should have an option when the shift-lock is enabled to have the character look parallel to where the mouse is like the original shif-lock and look pointed at the mouse.

local CameraModule = require(game.ReplicatedStorage.CameraService)

CameraModule:SetCameraView("ThirdPerson")

This is my main handler script in StarterGui.

Also in the main handler:

local cameraView = 1
game:GetService("UserInputService").InputBegan:Connect(function(a,p)
	if not p  then
		if a.KeyCode == Enum.KeyCode.C then
			if CameraView == 1 then
				CameraModule:SetCameraView("FirstPerson")
				CameraView = 2

			else
				CameraModule:SetCameraView("ThirdPerson")
				CameraView = 1

			end
		end
	end
end)

In a script thats in StarterCharacterScripts, I have just one line doing:

camMod:SetCameraView("ShiftLock")

Both firstperson and shiftlock, when enabled, doesn’t allow camera movement.

Your cameraView variable isn’t matching with the first C. That might be the reason why FirstPerson isn’t working, because it’s not triggering.

Since you’re setting both of these camera views at runtime once, I’m assuming that ThirdPerson simply just overrides and is the camera view you’re seeing. That could be the root of the unexpected behavior.

By any chance, are you using any other camera modules that might interfere with CameraService?

That’s weird. The camera did change though from first person to third person, and vice versa. It’s just that in the first person the camera doesn’t move.

I don’t believe that there is another camera module, however, I will take a look.

Is there possibly a way to print the current camera view?

1 Like

I’ve isolated the issue. So turns out it’s my viewportframe scripts causing it. I’m not entirely sure why atm.

The viewport frames seem to only break your camera system. It works with the normal camera.

EDIT: Same issue happens with another camera modules shiftlock system. Works with Roblox’s though. Not sure why viewport frame breaks custom ones.

ANOTHER EDIT: It seems to be because the CameraType is Scriptable? It has to be scriptable though so I’m not sure why.

EXPERIMENTATION: It seems the in the CameraService module code, Input.Delta for the onInputChange function is always 0,0,0 while in first person. (Input Object Delta Returning 0 Every Time - #7 by snorebear) possibly a mousebehavior issue?

Going back to the first assumption, I do believe this is an issue with viewport frames being in my UI… I’m not really sure why. In first person, before viewportframes are added, the mouse is locked to the center, after viewport frames are added though, the mouse can be moved around and the camera not.

My assumption there is that your mouse is interacting with ViewportFrames, which is reported as a game-processed event when UserInputService.InputChanged is called. This may have interfered with the camera views working as intended. You could disable the check if it’s a GPE or not manually (I think this is around line 285?), but you may encounter other wonky/unintended behaviors.

No it appears I’m wrong. I just commented all the viewport frame codes and it still didn’t work. Yet, I comment the whole script and it does, I’m going to do more digging to find out what it is. I’ll let you know if I encounter something that looks like its an error on the modules side.

Alright so obviously this is not your problem now since it is something on my side breaking it. But heres the issue if you have any ideas on what could be breaking it: The code runs 5 seconds after playstart. When I start playing, my mouse is locked to the center and i can move it fine. Once the code starts, the mouse gets free and the camera stops moving. There is nothing that uses the mouse in my code except :GetMouseLocation() and :GetMouse(), and all my ViewPortFrame code is disabled. I also tried disabling the gpe check.

Found the issue. It breaks when your UI has imagelabels with modal on.

̶I̶’̶v̶e̶ ̶r̶e̶a̶l̶l̶y̶ ̶b̶e̶e̶n̶ ̶d̶i̶g̶g̶i̶n̶g̶ ̶C̶a̶m̶e̶r̶a̶S̶e̶r̶v̶i̶c̶e̶ ̶a̶n̶d̶ ̶i̶t̶s̶ ̶a̶b̶i̶l̶i̶t̶i̶e̶s̶,̶ ̶t̶h̶o̶u̶g̶h̶ ̶I̶’̶m̶ ̶f̶i̶n̶d̶i̶n̶g̶ ̶i̶t̶ ̶a̶ ̶b̶i̶t̶ ̶u̶n̶f̶o̶r̶t̶u̶n̶a̶t̶e̶ ̶t̶h̶a̶t̶ ̶t̶h̶e̶ ̶C̶a̶m̶e̶r̶a̶ ̶i̶s̶ ̶l̶i̶m̶i̶t̶e̶d̶ ̶i̶n̶ ̶t̶h̶e̶ ̶Y̶ ̶d̶i̶r̶e̶c̶t̶i̶o̶n̶.̶ ̶T̶h̶e̶ ̶d̶e̶f̶a̶u̶l̶t̶ ̶R̶o̶b̶l̶o̶x̶ ̶c̶a̶m̶e̶r̶a̶ ̶l̶e̶t̶s̶ ̶y̶o̶u̶ ̶r̶o̶t̶a̶t̶e̶ ̶y̶o̶u̶r̶ ̶c̶a̶m̶e̶r̶a̶ ̶b̶a̶s̶i̶c̶a̶l̶l̶y̶ ̶f̶a̶c̶i̶n̶g̶ ̶s̶t̶r̶a̶i̶g̶h̶t̶ ̶d̶o̶w̶n̶ ̶t̶o̶w̶a̶r̶d̶ ̶t̶h̶e̶ ̶p̶l̶a̶y̶e̶r̶,̶ ̶t̶h̶o̶u̶g̶h̶ ̶C̶a̶m̶e̶r̶a̶S̶e̶r̶v̶i̶c̶e̶ ̶s̶e̶e̶m̶s̶ ̶t̶o̶ ̶c̶a̶p̶ ̶i̶t̶ ̶o̶f̶f̶ ̶a̶t̶ ̶s̶e̶e̶m̶i̶n̶g̶l̶y̶ ̶~̶3̶5̶°̶.̶
̶
̶I̶s̶ ̶t̶h̶e̶r̶e̶ ̶a̶n̶y̶ ̶w̶a̶y̶ ̶y̶o̶u̶ ̶o̶r̶ ̶I̶ ̶c̶o̶u̶l̶d̶ ̶r̶e̶m̶o̶v̶e̶ ̶t̶h̶i̶s̶ ̶l̶i̶m̶i̶t̶a̶t̶i̶o̶n̶?̶

I’ve figured it out, lines 194 and 303 were what I was looking for :+1:

1 Like

I do have a suggestion, I would love to see an option to control the cameras smoothness for position and rotation separately.

I’m finding that a higher smoothness value works great for when the player is walking around, but orbiting the camera around with a high smoothness just feels so sluggish and somewhat nauseating. It would be so awesome to be able to decouple these to allow separate smoothing values

1 Like

I’ll think about it when I have the free time. No guarantees, but definitely a good premise!

1 Like

Why duration? What if I want it to shake if a condition is met and then disconnect after said the condition is false.