[UNSOLVED] How to make camera tween behind player?

Basically I am making a camera fix script. I want the camera to tween back to behind the player… but when I try to do so, the camera does not go to the player. It will face the direction the player is facing like it is supposed to but it should also tween to behind the player so I was just wondering how I could go about doing so.

local TweenService = game:GetService("TweenService")
local goals, tweenInfo, tweens = {}, {}, {} --Used for tween service.
-------------------------------------------:
--Reset the frame:

--Set camera to face the same direction as player
goals[1] = {}
goals[1].CFrame = CFrame.lookAt(game.Workspace.CurrentCamera.CFrame.Position, game.Workspace.CurrentCamera.CFrame.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector)

tweenInfo[1] = TweenInfo.new(	
	0.5, --tween length
	Enum.EasingStyle.Quint, --easing Style
	Enum.EasingDirection.Out --easing Direction
)
tweens[1] = TweenService:Create(game.Workspace.CurrentCamera, tweenInfo[1], goals[1])
game.Workspace.CurrentCamera.CameraType = "Scriptable"

tweens[1]:Play()
tweens[1].Completed:Wait()
1 Like

Your goal CFrame is the cause of this. You should probably just use CFrame.new().

local hrp = game.Players.LocalPlayer.Character.HumanoidRootPart
local camera = workspace.CurrentCamera
local tgtCamPos = hrp.Position * Vector3.new(1, 0, 1) + camera.Position * Vector3.yAxis -- Set tgtPos to hrp at current cam altitude (looks like thats they way you have it)
tgtCamPos -= hrp.CFrame.LookVector * OFFSET

goals[1] = {
	CFrame = CFrame.new(tgtCamPos, hrp.Position)
}

EDIT: More changes incoming, accidentally tabbed and it sent the message.
NOTE: This might not be the correct way to position it the way you want it to be positioned, but using CFrame.new() is the way to go.

CFrame.new(IsAtThisPosition, LookingAtTheseCoords)

Interesting thought. It doesn’t work though like you said.

You should consider using Lerp() function in this case.
You must use the fact that you know how big step will be for the lerp. (1-(NextStepCFrame-CF2).Magnitude)/((C2-CF2).Magnitude)
image

I’m not sure I understand, can u elaborate?

ㅤㅤ
ㅤㅤ
ㅤㅤ
ㅤㅤ
ㅤㅤ
ㅤㅤ
ㅤ,

you mean like changing the view to third person permenatly?

When my code runs, the camera will tween into the direction the player is facing. I want it tween to the player as well in third person

Does not work


local TweenService = game:GetService("TweenService")
local goals, tweenInfo, tweens = {}, {}, {} --Used for tween service.
-------------------------------------------:
--Reset the frame:
local cff = game.Workspace.CurrentCamera.CFrame
game.Workspace.CurrentCamera.CFrame = CFrame.lookAt(game.Workspace.CurrentCamera.CFrame.Position, game.Workspace.CurrentCamera.CFrame.Position + game.Players.LocalPlayer.Character.Head.CFrame.LookVector)
local cff2 = game.Workspace.CurrentCamera.CFrame
game.Workspace.CurrentCamera.CFrame = cff

--Set camera to face the same direction as player
goals[1] = {}
goals[1].CFrame = cff2
--goals[1].CFrame = game.Players.LocalPlayer.Character.Head.CFrame
tweenInfo[1] = TweenInfo.new(	
	0.5, --tween length
	Enum.EasingStyle.Quint, --easing Style
	Enum.EasingDirection.Out --easing Direction
)
tweens[1] = TweenService:Create(game.Workspace.CurrentCamera, tweenInfo[1], goals[1])
game.Workspace.CurrentCamera.CameraType = "Scriptable"

tweens[1]:Play()
tweens[1].Completed:Wait()

STILL need help
ㅤㅤ
ㅤㅤ
ㅤㅤ
ㅤㅤ
ㅤㅤ
ㅤㅤ
ㅤㅤ

ㅤㅤ
ㅤㅤ