I want to be able to look at a model from a specific direction. The problem is that I don’t what the function name is.
What I tried so far is to write this piece of code to move the camera. The only problem is that I don’t know how to look at some specific orientation.
-- NOTE: I used the attempt found to fix the paddle focusing bug
-- here (https://devforum.roblox.com/t/how-can-i-focus-onto-a-part-using-the-camera/1512242)
-- to try
-- to align the camera
local camera = workspace.CurrentCamera
local gameboardPrimaryPart = gameBoard.PrimaryPart -- the part that is needed to focus in order to look at thegame board
local shouldPrint = true
wait(4) -- wait 4 seconds to wait for the player to load
camera.CameraType = Enum.CameraType.Scriptable
camera.Focus = focusPart.CFrame
camera:Interpolate(gameBoard.PrimaryPart.CFrame, focusPart.CFrame + Vector3.new(nil, nil, 1.5), 1)
camera.InterpolationFinished:Wait()
camera.CFrame = focusPart.CFrame + Vector3.new(nil, nil, 1.5)
I tried changing the camera look by changing it’s cframe by using various CFrame methods such as :Dots(Vector3) without any success. All it did was changing the view significantly
local part = workspace.Part
local camera = workspace.CurrentCamera
local tService = game:GetService("TweenService")
local tInfo = tweenInfo.new(1)
local props = {
CFrame = part.CFrame;
}
local tween = tService:Create(camera,tInfo,props)
tween:Play()
So the CFrame is always going to be consistent with the faces of the object. If you position the Camera to the CFrame + Left or Right of it, whatever orientation you want and then do the LookAt function, it should give you the desired result if I’m reading this right.
Your current code isn’t going to work right because you’re adding a CFrame and Vector3, which are two different data types. Try doing focusPart.CFrame * CFrame.new(0,0,1.5)
I ended up fixing the issue by using the constructor CFrame.new(Vector3, Vector3) to correct where it look at using the position of the model relative to my view block and the correct Normal Id. Here is how my code now look like:
-- NOTE: I used the attempt found to fix the paddle focusing bug
-- here (https://devforum.roblox.com/t/how-can-i-focus-onto-a-part-using-the-camera/1512242)
-- to try
-- to align the camera
local camera = workspace.CurrentCamera
local gameboardPrimaryPart = gameBoard.PrimaryPart -- the part that is needed to focus in order to look at thegame board
local shouldPrint = true
wait(2) -- wait 4 seconds to wait for the player to load
camera.CameraType = Enum.CameraType.Scriptable
camera.Focus = focusPart.CFrame
camera:Interpolate(gameBoard.PrimaryPart.CFrame, focusPart.CFrame + Vector3.new(nil, nil, 1.5), 1)
camera.InterpolationFinished:Wait()
camera.CFrame = focusPart.CFrame + Vector3.new(nil, nil, 1.5)
usefulFunctions.conmparePrint(focusPart.CFrame + Vector3.new(nil, nil, 1.5), camera.CFrame)
--camera.CFrame = CFrame.new(camera.CFrame.Position, Vector3:FromAxis(Enum.Axis.Back))
camera.CFrame = CFrame.new(camera.CFrame.Position, Vector3.FromNormalId(Enum.NormalId.Left))