Idea I want to lock the players camera so that he is forced to look at the specified area
Problem The problem is that the player is not focusing in the direction of the part, but the field of view is working.
Possibility I think that I am using focus, or I'm miss understanding it's use.
Code
plr = game.Players.LocalPlayer Char = plr.Character workspace.CurrentCamera.CameraType = "Scriptable" workspace.CurrentCamera.FieldOfView = 10 workspace.CurrentCamera.Focus = game.Part1.Position
How to Make a Camera Look in a Certain Direction
There are two ways to make a camera look in a certain direction. The first is using CFrames
and Vector3s
. The other is using Focus
. Both ways work differently, and you may have to use one way over another.
How would I do it with CoordinateFrame?
To this with CFrame, you must edit the CoordinateFrame property of the CurrentCamera. Here is an example:
local camera = game.Workspace.Camera camera.CameraType = Enum.CameraType.Scriptable camera.CoordinateFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(x,y,z))
This sets the location and where the camera is facing in one short, convenient code block.
How would I do so with Focus?
You would set up your code with CurrentCamera.Focus, and you need to use CFrame again.
local camera = game.Workspace.CurrentCamera local focuspart = game.Workspace.FocusPart --or whatever part you are trying to look at. camera.CameraType = Enum.CameraType.Scriptable camera.Focus = CFrame.new(focuspart.Position)
You don't need to involve a script, you can add a frame, size it to UDim2.new(1,0,1,0) and make the active property = true.