Need Help With Camera Stuff

Ok So Im Making A Doom 1993 Like Game And I Need Help Because Of Camera Stuff:

  1. What do you want to achieve? I Want To Make The Y Rotation Of The Camera Fixed Like You Cant Rotate The Camera Up And Down Like Doom 1993, I Saw Some Games Do It So I Know Its Possible

  2. What is the issue? I Have No Idea In How To Do That

  3. What solutions have you tried so far? I Tried Looking On The DevForum But No Luck, Not Even In Youtube, I Tried Using CFrames But It Looked Like A Wash Machine

So How Do I Do It?

7 Likes

Any time the player is happy, make them sad.

3 Likes

just realized that the post that i did has about the y position not the rotation lol (i mean the post not the topic)

1 Like
local runService = game:GetService("RunService")

local camera = workspace.CurrentCamera

local function renderStepped()
    local rotation = (camera.CFrame - camera.CFrame.Position)
    local rx, ry, rz = rotation:ToOrientation()

    camera.CFrame = camera.CFrame * CFrame.Angles(rx, 0, rz)
end

runService.RenderStepped:Connect(renderStepped)

Sorry for repost, I accidentally replied to someone else lmao

1 Like

it looks like a washing machine but you gived me a idea

1 Like

I’m confused about what you mean. Is it in the wrong direction? Try switching out the 0:

local runService = game:GetService("RunService")

local camera = workspace.CurrentCamera

local function renderStepped()
    local rotation = (camera.CFrame - camera.CFrame.Position)
    local rx, ry, rz = rotation:ToOrientation()

    camera.CFrame = camera.CFrame * CFrame.Angles(rx, ry, 0)
end

runService.RenderStepped:Connect(renderStepped)
1 Like

i tried but its the same thing, i cant record but imagine a camera rotating at INSANE speed, its what happen, the only thing that changes its the direction that it rotates

1 Like

let me test a thing really quick

1 Like

still nothing, do u have other ideas? i dont have alot of experience with cframes

1 Like

It still jiggles a tiny bit but I don’t feel like fixing it

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Shared = require(ReplicatedStorage:WaitForChild("Shared"))

local cam = nil

repeat
	cam = workspace.CurrentCamera
	task.wait()
until cam ~= nil

local guard = false

cam:GetPropertyChangedSignal("CFrame"):Connect(function()
	if guard == false then
		guard = true
		cam.CFrame += Vector3.yAxis * (cam.Focus.Position.Y - cam.CFrame.Position.Y)
		cam.CFrame = CFrame.lookAt(cam.CFrame.Position, cam.CFrame.Position + cam.CFrame.LookVector * Vector3.new(1, 0, 1))
		guard = false
	end
end)
2 Likes

if you are still confused about what i mean its this what i see (Loud Sound btw)

1 Like

perfect! thanks but could you explain? i really wanna learn about it, if you cant its okay

1 Like

First cam.CFrame line replaces the Y axis of cam by subtracting the current value and adding the value of the camera focus, so its at the same height as the focus. Second line tells the camera to face forward but ignore any Y component. guard is required otherwise changing the CFrame will call the function again in an infinite loop.

2 Likes

Thanks For Explaining It To Me :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.