Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make player camera face the direction of a certain part or just direction?

I was making a horror game and I wanted to place a few like mini jumpscares in which the player is forced to see them. I think it might have to do something with cframe angles, but I just can't figure it out. Additionally, I used the focus property and that did not work.

6 comments

0

Watch Previized's Camera Manipulation Video's

0

Will do.

0

I took a quick look at the videos and they do not answer my question. I did not mean in that way. I meant in a way where the camera is in the same location(player's first person view) but is forced to face towards a direction or part.

0

You need to get the camera and set its CFrame as the same as an invisible part with cancollide off, and make sure the front surface of the part is where you want it to be looking

0

use camera.Focus

0

camera.Focus = part will make the camera look at a part, remember to set your camera type to scriptable

1 answer

I finally found an answer with the Devforum!

local Camera = workspace.CurrentCamera
local Goal = game.Workspace.Part

local RS = game:GetService("RunService")
RS.Stepped:Connect(function()
	local LookDirection = CFrame.new(Camera.CFrame.Position, Goal.Position)
	local NewCFrame = CFrame.new(Camera.CFrame.Position) * LookDirection
	Camera.CFrame = Camera.CFrame:lerp(NewCFrame, .02)
end)

The link: https://devforum.roblox.com/t/camera-focus-on-a-part/472675/16

This discussion is preserved as it was. New answers, comments, and votes are closed.