#Tween: Camera
1 messages · Page 1 of 1 (latest)
ServerScriptService
local Workspace = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
local car = Workspace:WaitForChild("car")
local targetPosition = Workspace.Tween.Position
local startCFrame = car:GetPivot()
local currentRotation = startCFrame - startCFrame.Position
local cFrame = CFrame.new(targetPosition) * currentRotation
local tweenInfo = TweenInfo.new(
64.4,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In
)
local cFrameVal = Instance.new("CFrameValue")
cFrameVal.Value = car:GetPivot()
cFrameVal:GetPropertyChangedSignal("Value"):Connect(function()
car:PivotTo(cFrameVal.Value)
end)
local tween = TweenService:Create(cFrameVal, tweenInfo, {Value = cFrame})
tween:Play()
tween.Completed:Connect(function()
cFrameVal:Destroy()
end)
StarterPlayerScripts
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Camera = workspace.CurrentCamera
local camPart = workspace.car:WaitForChild("cam1")
Camera.CameraType = Enum.CameraType.Scriptable
local angleValue = Instance.new("NumberValue")
angleValue.Value = 0
local function updateCamera()
local baseCFrame = camPart.CFrame
local pos = baseCFrame.Position
local rotatedLookVector = (CFrame.Angles(0, angleValue.Value, 0) * baseCFrame.LookVector)
Camera.CFrame = CFrame.new(pos, pos + rotatedLookVector)
end
local connection = RunService.RenderStepped:Connect(updateCamera)
task.delay(60, function()
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local tween = TweenService:Create(angleValue, tweenInfo, {Value = math.pi})
tween:Play()
end)
bump
anyone
that's a really weird way to rotate a camera
why are you doing it like that
just tween the camera cframe
why do all that
but isnt cframe only for pos
cframe represents a position and a rotation
ok let me try
what do you mean the camera is "left behind"?
like it doesnt follow the serverscriptservice, cam part is welded to car and it stops after 64.4 secs
** You are now Level 6! **
so you want the camera to rotate 90 degrees over 2 seconds and then follow the car?