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

I Don't Quite Understand Camera.Focus Apparently.. Can Someone Help?

Asked by 6 years ago

Before I start..

local CamPart = game.Workspace:WaitForChild("CameraF"):WaitForChild("CamPos")
local FocusPart = game.Workspace:WaitForChild("CameraF"):WaitForChild("Focus")
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local CamWaitTime = 10

function CameraFunction()
    Camera.CameraSubject = CamPart
    Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = CFrame.new(-0, 66.675, 51.651)
    Camera.Focus = CFrame.new(CamPart.Position, FocusPart.Position)
end

CameraFunction()

All of this is in a LocalScript, yes.

My problem is simply the fact that Camera.Focus doesn't actually focus to the part I'd like it to. I've read so many things on websites and different ways of doing it but it just doesn't work. The camera looks in one direction always, and I can't seem to change that. Not sure what else to include so I'll just end it here.

Thanks for any help!

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Camera.Focus does not make the camera "face" a certain position. Our eye allows us to see an arc where we face, but the pupil is where we focus, and anything else we are not focusing at would look kinda blurry. Camera's Focus property is similar to this but instead of blur, it might not fully render.

Maybe you haven't looked far enough but this Roblox site explains it pretty well:

The Camera Focus is a CFrame that determines the area in 3D space the graphics engine will prioritize. Certain graphical operations Roblox performs, such as updating lighting, can take a lot of time or computational effort to complete. Focus tells Roblox the area in 3D space to prioritize when performing such operations. For example dynamic lighting from objects such as PointLights may not render at distances far from the Focus.

If your goal was to place a static camera at a location looking at something, Camera.CFrame should be what you should be focusing (lol) on. CFrame.new() accepts 2 arguments: the position and the lookAt. lookAt would be what the CFrame is "looking at". Here's how you might do it:

-- taken from your script
local CamPart = game.Workspace:WaitForChild("CameraF"):WaitForChild("CamPos")
local FocusPart = game.Workspace:WaitForChild("CameraF"):WaitForChild("Focus")

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable -- oh yeah and don't forget to set this if you want the camera to stay in position
camera.CFrame = CFrame.new(CamPart, FocusPart) -- here demonstrates CFrame.new(pos, lookAt)

There's alot more to it, if you want to create a cutscene or cinematics in your game this may be helpful.

0
Oh wow, thanks for this answer! I had no idea how to do this as I'm just learning Camera Manipulation. I've been putting it off for awhile so.. But yeah. Accepted answer. xXDoneBeingCoolXx 33 — 6y
Ad

Answer this question