Demo - Видео 13-07-2022 06:45:24.mp4
Game - Plaza X: Alpha - Roblox
how can I get such a smooth camera following the car? I tried TweenService, but it causes the camera to shake
Demo - Видео 13-07-2022 06:45:24.mp4
Game - Plaza X: Alpha - Roblox
how can I get such a smooth camera following the car? I tried TweenService, but it causes the camera to shake
If you set the camera type to scriptable, it will be smooth.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character.HumanoidRootPart
local Camera = workspace.CurrentCamera
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
Camera.CameraType = Enum.CameraType.Scriptable
local maxTiltX = 220
local maxTiltY = 105
Player.CharacterAdded:Connect(function(char)
if char:WaitForChild("Head") then
RootPart = char.HumanoidRootPart
wait(.5)
for index, value in ipairs(char:GetChildren()) do
if value:IsA("Part") or value:IsA("MeshPart") then
value.Transparency = 1
end
if value:IsA("Accessory") then
value:Destroy()
end
end
end
end)
-- CAMERA SYSTEM
RunService.RenderStepped:Connect(function(deltaTime)
local tweenInfo = TweenInfo.new(script:GetAttribute("Speed"),Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0)
local Goal = {
CFrame = RootPart.CFrame * CFrame.new(0, 1.8, 0) * CFrame.Angles(math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTiltY),math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTiltX),0)
}
local TweenCreate = TweenService:Create(Camera, tweenInfo, Goal)
TweenCreate:Play()
end)
Camera:GetPropertyChangedSignal("CameraType"):Connect(function()
Camera.CameraType = Enum.CameraType.Scriptable
end)
That’s (I believe) because you’re moving away from the camera, especially at a faster speed. You’ll want the camera’s position to constantly be locked where it should be, while only smoothing the camera’s orientation. You can also try lerping with delta, but I think a tween would be fine too as long as you constantly set the position of the camera. It’s been a little while since the last time I’ve done this.
Can you give an example of what I should have?
Actually my idea wasn’t as nice as I thought it would be. Maybe instead have a camera part constantly set the the position you want, then tween its orientation to what it needs to be. Also have the camera CFrame constantly set to that camera part. I’m sure there’s a better way, but it’s a thought.
This question is still relevant