You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make a cutscene where the camera is positioned at the camera part (which moves)
What is the issue? Include screenshots / videos if possible!
The issue is this:
As you can see in the video, instead of being at the (moving) part at all times, it’s jittery and won’t stay there.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
My model is moving using TweenService, and at first I was using an attachment for the camera position. It gave the same results as in the video. Then I used a welded part, and that was what I recorded the video with.
The camera should always be positioned at the part. Here’s (part of) my code: (sorry for the confusing variables)
local attach = prime:FindFirstChild("Attachment",true) --"Attachment", or "CamPos"
task.spawn(function()
cancel = false --cancel is just a bool
for v15 = 1, 10000000 do
task.wait();
if cancel then print("broken") break end;
u1.cam.CFrame = attach.WorldCFrame * u1.csgo; --u1 is a module and csgo is a camera shake offset
end;
end)
tweenCar:Cancel() --tweenCar is a tween for the car that I want to cancel
rv:PivotTo(rv.p1.Value) --rv is the car
ts:Create(rv.PrimaryPart,TweenInfo.new(4,Enum.EasingStyle.Exponential,Enum.EasingDirection.Out),{CFrame = rv.p2.Value}):Play() --moving the car
wait(1)
rv.JimmyNPCFake.Humanoid:LoadAnimation(rv.JimmyNPCFake.Folder.Button):Play() --an animation of the driver pushing the "pause" button on the music
task.wait(0.383) --how long it takes for his arm to move
script.Switch:Play() --switch sound
scene.Rock:Destroy() --music stop
ts:Create(rv.Panel.PausIn.Weld,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{C1 = CFrame.Angles(0,0,-28.207)}):Play() --button press down
I feel like this may have to do with the model tweening, but I can’t say for sure. Any help is appreciated!
local attach = prime:FindFirstChild("Attachment",true) --"Attachment", or "CamPos"
local rendersteppedconn = game:GetService("RunService").RenderStepped:Connect(function()
task.spawn(function()
cancel = false --cancel is just a bool
for v15 = 1, 10000000 do
task.wait();
if cancel then print("broken") rendersteppedconn:Disconnect() break end;
u1.cam.CFrame = attach.WorldCFrame * u1.csgo; --u1 is a module and csgo is a camera shake offset
end;
end)
end)
tweenCar:Cancel() --tweenCar is a tween for the car that I want to cancel
rv:PivotTo(rv.p1.Value) --rv is the car
ts:Create(rv.PrimaryPart,TweenInfo.new(4,Enum.EasingStyle.Exponential,Enum.EasingDirection.Out),{CFrame = rv.p2.Value}):Play() --moving the car
wait(1)
rv.JimmyNPCFake.Humanoid:LoadAnimation(rv.JimmyNPCFake.Folder.Button):Play() --an animation of the driver pushing the "pause" button on the music
task.wait(0.383) --how long it takes for his arm to move
script.Switch:Play() --switch sound
scene.Rock:Destroy() --music stop
ts:Create(rv.Panel.PausIn.Weld,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{C1 = CFrame.Angles(0,0,-28.207)}):Play() --button press down
I did something I’m not too proud of but it was only for learning purposes:
I went to the “toolbox” and then took a doors room 100 model.
Then I basically ransacked the thing until I found anything that looked like a camera position.
I found attachments named “CamPos1” and such, which were connected to the elevator. So then I assumed using attachments IS possible.
Long story short I used this code and and it worked:
local attach = rv.Panel:FindFirstChild("Base",true);
local offset = attach:FindFirstChild("Attachment",true);
local newCancelForSafe = false
local ticky = tick()
task.spawn(function()
task.wait()
for i = 1,10000000 do
task.wait()
if tick()-ticky >= 5 or rv == nil then break end
local tweenValue = ts:GetValue((tick()-ticky)/5,Enum.EasingStyle.Exponential,Enum.EasingDirection.Out)
rv:PivotTo(rv.origin.Value:Lerp(rv.p2.Value,tweenValue))
if not newCancelForSafe then
u1.cam.CFrame = offset.WorldCFrame * u1.csgo;
end
end
end)
wait(1)
rv.JimmyNPCFake.Humanoid:LoadAnimation(rv.JimmyNPCFake.Folder.Button):Play()
task.wait(0.345)
script.Switch:Play()
scene.Rock:Destroy()
ts:Create(rv.Panel.PausIn.Weld,TweenInfo.new(0.25),{C1 = CFrame.Angles(0,0,math.rad(-28.207))}):Play()
Basically instead of using tween:Play() I used tweenService:GetValue() and moved the model BEFORE positioning the camera, then do that every task. Thanks for your help everyone!