I would like some help with interpolating my camera. I'm currently creating a dialog GUI where it would interpolate the camera looking to the position of the person I am talking with. Currently, I base the position of the camera by 2x the distance of the person and my own character using :Lerp. This works fine unless the player speaks to the person at a very close distance (touching distance), where my player would not be able to be seen. This is a GIF of it:
https://gyazo.com/ffc136ea6220fce2200450c1e4c3af77
This is my current code:
function dialog:FocusTo(position) CurrentCamera.CameraType = Enum.CameraType.Scriptable local cframe = RootPart.CFrame local point = position:Lerp(cframe, 2) * CFrame.new(0,4,4) CurrentCamera:Interpolate(point, position, 0.4) end
I am very bad at vector maths, so what I want to do is to have the camera positioned 2x the distance between the person and the character, plus a fixed 20 studs so both the person and the character can be seen while talking. How can I add that 20 studs?
I managed to solve it, gives me what I want:
function dialog:FocusTo(position) CurrentCamera.CameraType = Enum.CameraType.Scriptable local cframe = RootPart.CFrame local point = position.p:Lerp(cframe.p, 2) local lookAt = RootPart.CFrame.p - position.p local unit = lookAt.unit --End point, add 5 studs to the camera height. local endpoint = CFrame.new(point + (unit * 5)) * CFrame.new(0,5,0) CurrentCamera:Interpolate(endpoint, position, 0.4) end