#How To Tween To a Position But Not Wait There

1 messages · Page 1 of 1 (latest)

dim wagon
#

QUESTION: How can I tween to a position but prevent the camera from coming to a full stop, instead treating the marked positions as checkpoints through which the camera must pass but must not stop?

Below is the code that handles the position tweening. This is an excerpt from a larger function a part of a module I am working on for my game called CutsceneService.

local function playNextTween(currentIndex)
        if currentIndex > #cameraData then
            task.wait(completionWait)
            camera.CameraType = Enum.CameraType.Custom
            return
        end

        local targetData = cameraData[currentIndex]
        local shouldSkipPause = targetData.part:GetAttribute("SkipPause") == true

        local tween = TweenService:Create(
            camera,
            tweenInfo,
            {CFrame = targetData.cframe}
        )

        if shouldSkipPause then
            tween:Play()
            -- Something here such that the camera will make it the position but not stop there
            -- As of now, anything with SkipPause == true will simply be ignored :(
            playNextTween(currentIndex + 1)
        else
            tween.Completed:Connect(function()
                playNextTween(currentIndex + 1)
            end)
            tween:Play()
        end
    end

If more of the module is required in order to solve the problem, I am happy to provide it.

Below is a video of the behavior that happens now given this code, as well as some visual insights into how the system works:

steel hearth
dim wagon