#Tween: Camera

1 messages · Page 1 of 1 (latest)

misty mauve
#

For some reason the camera is left behind during the tweening.

#

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)
misty mauve
#

bump

misty mauve
#

anyone

quick vortex
#

why are you doing it like that

misty mauve
#

i dont really know how to rot cameras

#

this is like 15 minutes of work

#

idrk loll

quick vortex
#

why do all that

misty mauve
#

but isnt cframe only for pos

quick vortex
misty mauve
#

ok let me try

quick vortex
#

what do you mean the camera is "left behind"?

misty mauve
#

like it doesnt follow the serverscriptservice, cam part is welded to car and it stops after 64.4 secs

crystal streamBOT
#

studio** You are now Level 6! **studio

quick vortex
#

so you want the camera to rotate 90 degrees over 2 seconds and then follow the car?

misty mauve
#

no 180

#

because the car is pointing to people who are sitting i want it to turn to hte front view