Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Camera Interpolation isn't working?

I was originally trying to make a cutscene script, but it wouldn't work thanks to this problem. I put this new code in a LocalScript in StarterPack.

I have everything how it should be (script is a LocalScript, correct CameraType, etc.), yet using the method :Interpolate() doesn't work. It's like it gets ignored.

The CameraType gets set to Scriptable, then the script runs over the Interpolate line, and continues.


Here is the code:

repeat wait() until game.Players.LocalPlayer.Character
wait(2)
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
game.Workspace.CurrentCamera:Interpolate(CFrame.new(Vector3.new(0,20,0),Vector3.new(0,0,0)),CFrame.new(Vector3.new(0,50,0),Vector3.new(0,0,0)),10)
wait(2)
print("didn't break")

NOTE: Sometimes I come across bugs in Studio that only happen in one place, if I make another place the bug will be gone. I don't believe this is one of those, though.

Thank you!

Hopefully someone can help me.

~TDP

3 comments

0

Why not just use the camera's coordinate frame?

0

The interpolation service is broken as of right now, I believe.

0

Thanks. Well, I'm not really advanced enough to manually code the interpolation.

1 answer

✓ Accepted answer

Don't know for myself, but from what others said it seems that it's broken right now. Making your own interpolation wouldn't be that hard, especially since there is the CFrame:Lerp method, which will do the toughest part for you.

local renderStep = game:GetService("RunService").RenderStepped

-- This solution would work only with animating object one at the time
-- Animating several objects is a bit different process
local timer = 0
function interpolate( obj, start, endCf, time )
    -- We'll use different variable to see how far into the animation we are
    while time > t do
        -- RenderStepped returns the time passed since last call
        local delta = renderStep:wait()
        -- The second argument represents how far to move the object.
       -- if it's 0, it will match start CFrame, if it's 1 it will match end CFrame. Anything inbetween is interpolated
        obj.CFrame = start:lerp( endCf, timer/t )
        -- Keep track of how long we are animating this
        timer = timer + delta
    end
    -- You have to manually set the end CFrame, incase it's bit off
    obj.CFrame = endCf
    timer = 0
end

interpolate( camera, CFrame.new(Vector3.new(0,20,0),Vector3.new(0,0,0)),CFrame.new(Vector3.new(0,50,0),Vector3.new(0,0,0)),10 )

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.