Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years 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 1537 — 4y
0
Will do. theGoodpancake 5 — 4y
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 — 4y
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 407 — 4y
View all comments (2 more)
0
use camera.Focus Leamir 3138 — 4y
0
camera.Focus = part will make the camera look at a part, remember to set your camera type to scriptable Leamir 3138 — 4y

1 answer

Log in to vote
0
Answered by 4 years 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