hey so I have this over the shoulder cam system I made with the help of youtube a while back and I want to be able to switch shoulders smoothly and make it not look like it’s just teleporting into the other shoulder position, some parts of the script aren’t used as I don’t like them for my system but they are still in there, there should also be some notes that help me guide my script so they might help you too, any help is appreciated.
Example of what i want, a smooth tween looking thing:
https://gyazo.com/e045c1a68714691b4b89930ff985f0b0
Script:
local players = game:GetService("Players")
local contextactionservece = game:GetService("ContextActionService")
local RunService = game:GetService("RunService")
local UserInput = game:GetService("UserInputService")
local TweenServ = game:GetService("TweenService")
--------
local Camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local cameraOffset = Vector3.new(1.5, 2, 12)
local OGcameraOffset = Vector3.new(1.5, 2, 12)
local cameraOffset2 = Vector3.new(-1.5, 2, 12)
local isRight = true
-----------------------------------------------------------------------
player.CharacterAdded:Connect(function(character)
-- actual camera function, i.e positioning
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local cameraAngleX = 0
local cameraAngleY = 0
local function playerInput (actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Change then
cameraAngleX -= inputObject.Delta.X
cameraAngleY = math.clamp(cameraAngleY - inputObject.Delta.Y * 0.4, -75, 75)
end
end
contextactionservece:BindAction("PlayerInput", playerInput, false, Enum.UserInputType.MouseMovement, Enum.UserInputType.Touch)
RunService:BindToRenderStep("CameraUpdate", Enum.RenderPriority.Camera.Value, function()
local startCFrame = CFrame.new(rootPart.CFrame.Position) * CFrame.Angles(0, math.rad(cameraAngleX), 0) * CFrame.Angles(math.rad(cameraAngleY), 0, 0)
local cameraCFrame = startCFrame:PointToWorldSpace(cameraOffset)
local cameraFocus = startCFrame:PointToWorldSpace(Vector3.new(cameraOffset.X, cameraOffset.Y, -1000000))
-- sensitivity
UserInput.MouseDeltaSensitivity = 0.5
--
Camera.CFrame = CFrame.lookAt(cameraCFrame, cameraFocus)
-- shift lock
--local lookingCFrame = CFrame.lookAt(rootPart.Position, Camera.CFrame:PointToWorldSpace(Vector3.new(0, 0, -1000000)))
--rootPart.CFrame = CFrame.fromMatrix(rootPart.Position, lookingCFrame.XVector, rootPart.CFrame.YVector)
--humanoid.AutoRotate = false
--
-- clipping
local Character = game.Players.LocalPlayer.Character
local CameraRay = Ray.new(Character.Head.Position, Camera.CFrame.Position - Character.Head.Position)
local Ignore = {Character}
local HitPart, HitPosition = game.Workspace:FindPartOnRayWithIgnoreList(CameraRay, Ignore)
Camera.CFrame = (Camera.CFrame - (Camera.CFrame.Position - HitPosition)) + (Character.Head.Position - Camera.CFrame.Position).Unit
--
end)
end)
------------------------------------------------------------------------
local function focusControl(actionName, inputState, inputObject)
--mouse control / locking center
Camera.CameraType = Enum.CameraType.Scriptable
UserInput.MouseBehavior = Enum.MouseBehavior.LockCenter
--UserInput.MouseIconEnabled = false //MAKE MOUSE GO ICON GO POOF
contextactionservece:UnbindAction("FocusControl")
end
contextactionservece:BindAction("FocusControl", focusControl, false, Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch, Enum.UserInputType.Focus)
-- change shoulder ---------------------------------------
local function inputBegan(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.T then
if not gameProcessedEvent then
if isRight == true then
cameraOffset = cameraOffset2
isRight = false
else
cameraOffset = OGcameraOffset
isRight = true
end
end
end
end
end
UserInput.InputBegan:Connect(inputBegan)