[UNSOLVED] Making A Silent Hill 2 Esk Camera

Sup. I am making a silent hill 2 esk game, and I am working on the camera system and the system I made is not really what I am looking for. So I took to dev forum, and was wondering how I could make something similar to this video?
Here it is:


My code so far:

local RunService = game:GetService("RunService")	

local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer


local CAMERA_OFFSET = Vector3.new(-1,30,0)
camera.CameraType = Enum.CameraType.Scriptable


local function onRenderStep()

	if player.Character then
		local playerPosition = player.Character.HumanoidRootPart.Position
		local cameraPosition = playerPosition + CAMERA_OFFSET

		camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
	end
end

RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
1 Like

Tried changing the rotation but I couldn’t get it at the right angle.

Update, over the past few days i’ve tried various ways and it still won’t work. I don’t know why but I can’t get the camera to sort of rotate with the player.

Have you tried CFrame.Angles?

I have but I don’t know exactly how to get these angles.

You mean getting the rotation of the camera? Or do you not know how you use CFrame.Angles?

Getting the rotation of the camera similar to the image provided above.

One problem I saw in your script was that you used camera.CoordinateFrame which is deprecated change that to camera.CFrame.

(and i’m working for a solution so the cam can rotate just like u want)

Alright thanks! I’ll just be browsing around for a bit. I’ll change it in a minute.

local RunService = game:GetService("RunService")	

local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer

local uis = game:GetService("UserInputService")



local CAMERA_OFFSET = Vector3.new(-1,30,0)
camera.CameraType = Enum.CameraType.Scriptable


local function onRenderStep()

	if player.Character then
		local playerPosition = player.Character.HumanoidRootPart.Position
		local cameraPosition = playerPosition + CAMERA_OFFSET
        uis.InputBegan:Connect(function(input, gameProcessedEvent)
           if input.UserInputType == Enum.UserInputType.KeyBoard then
               if input.KeyCode == Enum.KeyCode.D then
                  camera.CFrame = Vector3.Angles(change this to the rotation you want to have when the player moves to the right)

                  elseif input.KeyCode == Enum.KeyCode.A then
                    camera.CFrame = Vector3.Angles(change this to the rotation you want to have when the player moves to the right)
                 elseif input.KeyCode == Enum.KeyCode.A and input.KeyCode == Enum.KeyCode.W then
camera.CFrame = Vector3.Angles(change this to the rotation you want to have when the player moves to the right)
               end
            end
        end)

		camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
	end
end

RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

The script isn’t finished completely and i’m not sure if it will work. So where input.KeyCode == Enum.KeyCode.A is do that more times so u have A, A/W, D, A/S, D/S, D/A so when the player presses both A and D it will rotate.

DO NOTICE THAT THERE ARE SOME TYPOS IN IT SO CHANGE IT IN STUDIO CAUSE I MADE IT IN POST.

If it doesn’t works i’ll change it in the hope it will work but maybe the script inspires you so u can do it yourself.

Alright thanks, i’ll go mess around with it and see what turns up!

One thing I am unsure on is where to move the camera on the keycode parts. I am unfamiliar with this and unsure which way it should go or what number’s to put in the parameters.

Do you have any ideas what I could possibly the rotations to?

You mean on X/Y/Z axes? I’m not quite sure but I think the X as or the Y as.

So just like you did here before:

local CAMERA_OFFSET = Vector3.new(-1,30,0)

But then with Vector3.Angles(0,30,0–something like that just try everything with that on the X/Y/Z axes).

I am running into a error on line 20 of

KeyBoard is not a valid member of "Enum.UserInputType" 

I am unsure what this would be invalid.

Is this that line:

if input.UserInputType == Enum.UserInputType.KeyBoard then

Correct. That is the line that produced the error for some reason.

I simply have no idea why it says that error. Maybe remove gameProcessedEvent since your not using it. Pretty sure it won’t fix the problem but I might be wrong.

Hmmm. I’ll go see if that is the issue.

Hey, so I removed the line causing that error and it seemed to fix it. However, on this line


				elseif input.KeyCode == Enum.KeyCode.A then
					camera.CFrame = Vector3.Angles(-1, 11.85, 0)

I put the number’s there however I get this error:

Workspace.GrumpyCools.LocalScript:25: attempt to call a nil value 

Any idea on how to fix this?