New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 9 days ago

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.

0
Watch Previized's Camera Manipulation Video's killerbrenden 1306 — 9d
0
Will do. theGoodpancake 5 — 9d
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. theGoodpancake 5 — 9d
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 DarkDanny04 310 — 8d
View all comments (2 more)
0
use camera.Focus Leamir 2175 — 8d
0
camera.Focus = part will make the camera look at a part, remember to set your camera type to scriptable Leamir 2175 — 8d

1 answer

Log in to vote
0
Answered by 8 days ago

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

Ad

Answer this question