Help with the a custom 360 camera script (Look up and down freely)

Basically, I am trying to make a camera script where you can look up and down from any direction
for my space game. (Example Roblox game I wanted: the future)
Link: [Voice Chat!!] 🗺️NEW MAP🗺️ the future - Roblox

The problem is it glitches when I look up and down (or above rotation degrees as 81) I don’t want that to happen. I also want it without making camera as scriptable, (For first person and third person, Mainly for first person). Apparently I tried adding the camera subject to the humanoid but it does nothing, I tried looking or searching up similar posts but I can’t find them too, well I found a few but it’s not what I wanted.

Video showing the problem: https://gyazo.com/2d51428999d2b5287568718942f48c01

Here’s the code.

local uis = game:GetService("UserInputService")
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character

uis.InputChanged:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseMovement then
		local delta = uis:GetMouseDelta()
		print(delta)
		local X = delta.X
		local Y = delta.Y
		cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(-Y),math.rad(-X),math.rad(0))
	end
end)
5 Likes

Maybe this helps you. Customizing the Camera | Documentation - Roblox Creator Hub

1 Like

I believe this post is what you are looking for and unfortunately yeah.

the camera will have to be scriptable or else the glitch will happen as the default camera script prevents the camera from going over the 81 degree zone.

2 Likes

When I set it to scriptable, It breaks the script (No errors though, maybe it overrides the script, I can’t move my camera and it’s not focusing the character.)
https://gyazo.com/fda3766b27df54bb745f8e4bbdb2019c

1 Like

I don’t find it helpful to me, still it doesn’t fix my problem.

1 Like

Also I meant to reply to you but I forgot to, at message 4.

1 Like

Making the camera type scriptable doesn’t break your script, it just disables most of the default camera behavior allowing you to script your own. I’m not experienced with camera manipulation but the link @CRAFTRONIX_457 sent should help you.

1 Like

I cannot find anything useful and anything that helps there.

1 Like

But is there still a way to make it work without scriptable or I can’t?

1 Like

Please refer to the post I linked above @CDDevelopment has mentioned about it already.

I did what u said, It works when I rotate. But not when I move my character. I cannot do this but what I can think of is I want to get its lookvector for head (in line 7), but if I added code at line 7 to renderstep, it will just override, glitches and cannot rotate. How can I do that?

Gyazo (also this camera is mainly for first person, char visible because I set the CameraMode to classic so you can see char.): https://gyazo.com/5bced98e872cca80b85bb926e2af901a

Code if needed:

wait(1)
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = plr.Character.Head.CFrame -- how do i get its lookvector? (Also for first person) and i didnt add it in renderstep because it will override the rotation  

rs.RenderStepped:Connect(function(step)
	uis.MouseBehavior = Enum.MouseBehavior.LockCenter
	local delta = uis:GetMouseDelta()
	--print(delta)
	local x = delta.X
	local y = delta.Y
	cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(-y),math.rad(-x),math.rad(0))
end)```

I still need help with this script

Try creating a new variable that describes the total orientation, then apply that to the head CFrame instead of the delta

Ok I will try doing that what u said.

I cannot do that because it would just glitch the camera rotation and I cannot really move it, I still will go for getting the mouse delta.

Make your script a local script, name it “Camera” and parent it to StarterPlayerScripts.

It is a local script and it is in StarterPlayerScripts.

What is the name of the local script? Also when using scriptable, you will have to set the camera subject to the player’s character’s humanoid.

Side note:
RenderStepped fired every render frame, which will fire at a rapid pace witch explains why it appears not to go.

I don’t think it’s necessary to know the name but the name is customCameraScript

It doesn’t work when i change camera subject to the player’s character’s humanoid.

The local script has to be named “Camera” in order to work. Have no idea why this is the case, but I think you should try it.

1 Like