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

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

Asked by
Neu_Dev 22
4 years ago

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)
0
workspace.CurrentCamera.CFrame =CFrame.new(workspace.CurrentCamera.CFrame.p, workspace.Part) ??? royaltoe 5144 — 4y
0
^ starmaq 1290 — 4y
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 Neu_Dev 22 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
0
where did you get the NEWHEIGHT? Neu_Dev 22 — 4y
Ad

Answer this question