You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? !
Trying to fix isometric camera rotation tweening -
What is the issue?
The Camera Jerks up whenever I rotate it around the player, it works perfectly fine when I don’t tween it
-
What solutions have you tried so far?
I looked over the devforum and I couldn’t find anything on it
--// Services
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
-- // Settings
local FOV = 10
local HeightOffset = 100
local XOffset = 50
local ZOffset = 50
local RotationSpeed = 10
-- // Code
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Camera = game.Workspace.CurrentCamera
Camera.FieldOfView = FOV
if Camera.CameraType ~= Enum.CameraType.Scriptable then Camera.CameraType = Enum.CameraType.Scriptable end
local angleY = 45
UserInputService.InputChanged:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent and input.UserInputType == Enum.UserInputType.MouseWheel then
angleY = angleY + input.Position.Z * RotationSpeed
end
end)
RunService.RenderStepped:Connect(function()
local X_Distance = (Distance + XOffset) * math.cos(math.rad(angleY))
local Z_Distance = (Distance + ZOffset) * math.sin(math.rad(angleY))
local Vector = Vector3.new(
HumanoidRootPart.Position.X + X_Distance,
HumanoidRootPart.Position.Y + HeightOffset,
HumanoidRootPart.Position.Z + Z_Distance
)
if Character then
--Camera.CFrame = CFrame.new(Vector, HumanoidRootPart.Position)
TweenService:Create(Camera, TweenInfo.new(0.1, Enum.EasingStyle.Linear), {CFrame = CFrame.new(Vector, HumanoidRootPart.Position)}):Play()
end
end)