I have this to make the game be in isometric view point (from the corner basically) and I have a recoil effect in it to move the camera when they hold left click, and while this works it’s very jittery and jerky when moving while shooting but it looks decent when standing still.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local eventsFolder = ReplicatedStorage.Events
local StarterPlayer = game.StarterPlayer
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
local CAMERA_DEPTH = 30
local HEIGHT_OFFSET = 3
local NORMAL_FIELD_OF_VIEW = 30
camera.FieldOfView = NORMAL_FIELD_OF_VIEW
local function onWheelBackward()
if CAMERA_DEPTH < 50 then
CAMERA_DEPTH = CAMERA_DEPTH + 2
end
end
mouse.WheelBackward:Connect(onWheelBackward)
local function onWheelForward()
if CAMERA_DEPTH > 30 then
CAMERA_DEPTH = CAMERA_DEPTH - 2
end
end
mouse.WheelForward:Connect(onWheelForward)
local function updateCamera()
local character = player.Character
if character then
local root = character:FindFirstChild("HumanoidRootPart")
if root then
local rootPosition = root.Position + Vector3.new(0, HEIGHT_OFFSET, 0)
local cameraPosition = rootPosition + Vector3.new(CAMERA_DEPTH, CAMERA_DEPTH, CAMERA_DEPTH)
camera.CFrame = CFrame.lookAt(cameraPosition, rootPosition)
end
end
end
local cam = workspace.CurrentCamera
local TS = game:GetService("TweenService")
local recoilDirection = Vector3.new(0, 0.5, 0) -- Adjust the recoil direction
local recoilIntensity = 1 -- Adjust the recoil intensity
local function recoil()
local oldCFrame = cam.CFrame
local newCFrame = oldCFrame * CFrame.Angles(math.rad(recoilDirection.X * recoilIntensity), math.rad(recoilDirection.Y * recoilIntensity), math.rad(recoilDirection.Z * recoilIntensity))
local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local tweenProperties = {CFrame = newCFrame}
local recoilTween = TS:Create(cam, tweenInfo, tweenProperties)
recoilTween:Play()
-- Snap back to original position after recoil
wait(0.1)
local resetTween = TS:Create(cam, tweenInfo, {CFrame = oldCFrame})
resetTween:Play()
end
eventsFolder.RecoilEvent.OnClientEvent:Connect(recoil)
RunService:BindToRenderStep("IsometricCamera", Enum.RenderPriority.Camera.Value + 1, updateCamera)
heres the whole code but the part to focus on mostly is just the recoil function, I’ve tried tweening and Cframe with this working the best out of them but with it not working to well when moving, any way to fix this?