Hey guys! I’m currently struggling to be able to adapt my camera to work of how i want it to, here’s a video of the issue!
I wish to make the camera also face the same direction as the humanoidrootpart while having a constant offset, similar to a over the shoulder camera.
Why not just use attach? Well it leads to some very funky results:
Here’s my current script relating to the camera!
Run_Service.RenderStepped:Connect(function()
if Character and Humanoid_Root_Part and Equip == true then
local NewCFrame
Closest_Player = GetClosest()
--print(Closest_Player)
if not Closest_Player then
Character.Humanoid:UnequipTools()
Enemy_Remote:FireServer("Combat ended")
end
if Closest_Player then
lookAt(Character, Closest_Player)
--lookAt(game.Players.LocalPlayer.Character, Closest_Player)
--Body_Gyro.CFrame = CFrame.new(Humanoid_Root_Part.Position, Closest_Player.Character.HumanoidRootPart.Position)
if Switcher == false then
Last_Player = Closest_Player
Switcher = true
end
if Last_Player == Closest_Player then
else
Enemy_Gui_Clone.Enabled = false
Enemy_Gui_Clone.Parent = Closest_Player.Character.HumanoidRootPart
Enemy_Gui_Clone.Adornee = Closest_Player.Character.HumanoidRootPart
Enemy_Gui_Clone.Enabled = true
Last_Player = Closest_Player
end
end
--print(Closest_Player)
if Fired == false then
print(Closest_Player)
Enemy_Remote:FireServer(Closest_Player)
print("Fired!")
Fired = true
end
local Start_CFrame = CFrame.new((Humanoid_Root_Part.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, math.rad(X_Angle), 0)*CFrame.Angles(math.rad(Y_Angle), 0, 0)
local Camera_CFrame = Start_CFrame + Start_CFrame:vectorToWorldSpace(Vector3.new(Camera_Position.X,Camera_Position.Y,Camera_Position.Z))
local Camera_Focus = Start_CFrame + Start_CFrame:vectorToWorldSpace(Vector3.new(Camera_Position.X,Camera_Position.Y,-50000))
Player_Camera.CFrame = CFrame.new(Camera_CFrame.p,Camera_Focus.p)
--local lookVec = Character:WaitForChild("HumanoidRootPart").CFrame.LookVector
--local Test = CFrame.lookAt(Player_Camera.CFrame.Position, Player_Camera.CFrame.Position + lookVec)
--Player_Camera.CFrame = CFrame.new(Camera_CFrame.p,Camera_Focus.p)
end
end)
And then just specifically the camera part, if you want it in a easier to read way:
local Start_CFrame = CFrame.new((Humanoid_Root_Part.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, math.rad(X_Angle), 0)*CFrame.Angles(math.rad(Y_Angle), 0, 0)
local Camera_CFrame = Start_CFrame + Start_CFrame:vectorToWorldSpace(Vector3.new(Camera_Position.X,Camera_Position.Y,Camera_Position.Z))
local Camera_Focus = Start_CFrame + Start_CFrame:vectorToWorldSpace(Vector3.new(Camera_Position.X,Camera_Position.Y,-50000))
Player_Camera.CFrame = CFrame.new(Camera_CFrame.p,Camera_Focus.p)
--local lookVec = Character:WaitForChild("HumanoidRootPart").CFrame.LookVector
--local Test = CFrame.lookAt(Player_Camera.CFrame.Position, Player_Camera.CFrame.Position + lookVec)
--Player_Camera.CFrame = CFrame.new(Camera_CFrame.p,Camera_Focus.p)
The commented out code makes the camera rotate the same direction as the humanoidrootpart, which may be useful but i’m not sure. Could anyone please help me out? I’d appreciate it a ton!