Problem facing camera to part lookvector

Hey devforum, I made a plane and I am trying to loop the camera to face where the plane is facing, but this is happening:

https://gyazo.com/a092c2f661a2daa36dd134de408089a1

This is how I am doing it:

camera.CFrame = CFrame.new(camera.CFrame.Position, planeModel.Body.CFrame.LookVector)

Thanks for reading.

For CFrame.new(arg1,arg2) to work, you will need the second argument to be the look at a point in terms of the world.

local camPos = camera.CFrame.Position
local lookVector = planeModel.Body.CFrame.LookVector
camera.CFrame = CFrame.new(camPos,camPos+lookVector)

Here is the vector diagram I drew for a different problem with a fly script but a similar scenario with vector maths to obtain the lookAt point.

1 Like

Thanks, it fixed it. But I have another doubt, is there any way of simulating a body gyro? I want the camera to turn smoothly.

If you want the camera to turn smoothly then that means you need to generate intermediate CFrame using lerping which can be done like so separating position and rotation of a CFrame and lerping the current CFrame rotation towards the goal CFrame rotation.

local camPos = camera.CFrame.Position
local lookVector = planeModel.Body.CFrame.LookVector

local goalCFrame = CFrame.new(camPos,camPos+lookVector)

local lerpToGoalCFrame = camera.CFrame:lerp(goalCFrame,0.25)--0.25 can be anything you want
local rotationOnlyOfLerp = lerpToGoalCFrame-lerpToGoalCFrame.Position

camera.CFrame = CFrame.new(camPos)*rotationOnlyOfLerp

1 Like