Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i follow LookVector camera's X- Axis?

how do you implement camera's lookvector looking down or up to the part


Right now achieved getting the Left and Right camera's axis here's my script:

local cam = Camera.CFrame.LookVector
local Rot1 = math.atan2(-cam.X, -cam.Z)
local CamLookAt = CFrame.new(Torso.Position) * CFrame.Angles(0, Rot1, 0)
Seat.CFrame = CamLookAt --// the seat copy's my camera's lookvector but only left and right.

But now i want to implement up and down lookvector of the camera to the part.

which is the X axis and i tried doing this i have no idea.

Rot2 = math.rad(cam.X)
local CamLookAt = CFrame.new(Torso.Position) * CFrame.Angles(Rot2, Rot1, 0)

3 comments

0

workspace.CurrentCamera.CFrame =CFrame.new(workspace.CurrentCamera.CFrame.p, workspace.Part) ???

0

^

0

this is not what i'm looking for since this, your telling me the camera is gonna look on the part, i wan't the part's lookvector which it's front to look at same as where i am looking at

1 answer

Keep the X and Z axis of the LookVector and set the Y to the Y (height) of the object you want to look up/down at.

Example:

local oldLook = Camera.CFrame.LookVector
Camera.CFrame = CFrame.new(Camera.CFrame.Position, Vector3.new(oldLook.X, NEW HEIGHT (Y), oldLook.Z)

1 comment

0

where did you get the NEWHEIGHT?

This discussion is preserved as it was. New answers, comments, and votes are closed.