Why isn't this working for me?
local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable local endPosition = container:WaitForChild(script.Set.Value).Cameras:WaitForChild(script.Camera.Value).CFrame local look = container:WaitForChild(script.Set.Value).Cameras:WaitForChild(script.Camera.Value).CFrame+container:WaitForChild(script.Set.Value).Cameras:WaitForChild(script.Camera.Value).CFrame.lookVector local duration = 2 camera:Interpolate(endPosition,look,duration)
Please be aware that Interpolate currently doesn't work correctly in Studio and you should test this in game.
Firstly, :Interpolate
takes three arguments: endPosition
, endFocus
and duration
.
This code must be run in a LocalScript
and the CameraType
must have been set to scriptable
.
The endPosition argument is where the camera will physically end up, for example:
local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera:Interpolate(workspace.TestPart.CFrame, someFocusCFrame, 1)
The camera would smoothly tween to the middle of this part.
endFocus is a little different however, endFocus is the position the camera will face when it finishes tweening.
For example:
local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable local focus = workspace.TestPart.CFrame + workspace.TestPart.CFrame.lookVector camera:Interpolate(workspace.TestPart.CFrame, focus, 1) -- this will cause the camera to smoothly tween into the middle of the part and also face the same way as the part.
It can be handy to store an array of parts/Positions to interpolate too, for example:
local targets = {PosOne, PosTwo, PosThree, endFocus} local duration = 1 for i=1, #targets-1 do camera:Interpolate(CFrame.new(targets[i]), CFrame.new(targets[i], targets[i+1]), duration) wait(duration) end camera.CameraType = Enum.CameraType.Custom
Yes, it is. This is how you use it:
local startPos = CFrame.new(position,lookAt) -- where the tweening starts local endPos = CFrame.new(position,lookAt) -- where it ends local duration = 2 -- how long it takes to tween cameraObject:Interpolate(startPos,endPos,duration)
Notes:
LocalScripts
CameraType
has to be set to Scriptable
for this to work.Wiki article: http://wiki.roblox.com/index.php?title=API:Class/Camera/Interpolate
Hope I helped :)
~TDP