Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is camera tweening a thing?

Asked by
ItsMeKlc 235 Moderation Voter
8 years ago

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)
0
Are you testing this in studio? I can't really tell what this code is doing without seeing the explorer view. DevSean 270 — 8y
0
It's complicated, but that parts fine... It basically leads to a part ItsMeKlc 235 — 8y
0
You haven't asnwered my question about if you're testing in studio or not. (Studio testing is currently broken with interpolate) DevSean 270 — 8y
0
Oh yeah I am testing in studo ItsMeKlc 235 — 8y
View all comments (2 more)
0
Publish the game as a new place and test it there DevSean 270 — 8y
0
Oh okay it works thanks! ItsMeKlc 235 — 8y

2 answers

Log in to vote
0
Answered by
DevSean 270 Moderation Voter
8 years ago

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, endFocusand 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
0
I can't see your code in a comment, what is your duration set to and are you testing this in studio? DevSean 270 — 8y
0
I'm sorry I was to hasty, it still isn't working for me... I'll post my code in my post ItsMeKlc 235 — 8y
Ad
Log in to vote
-1
Answered by 8 years ago

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:

  • This is recommended to be used in LocalScripts
  • The CameraObject's 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

0
I just tried it and it didn't tween... It just snapped.... Why? For start position I used camera.CFrame, is that the issue? ItsMeKlc 235 — 8y
0
camera.CoordinateFrame is what you use TheDeadlyPanther 2460 — 8y
0
make sure that the two CFrames are actually different. XAXA 1569 — 8y
0
^ TheDeadlyPanther 2460 — 8y

Answer this question