Hi, im making a viewmodel with an animated camera. But, the camera seems to move down (or up it might depend) and not stay in one place. How would I fix that? I’ve searched in the devforum but not even one helped on my problem.
local offsetCFrame = viewmodel.Torso.CFrame:ToObjectSpace(viewmodel.Camera.CFrame) local viewmodelPos = camera.CFrame * attributes.offset viewmodel:PivotTo(viewmodelPos) camera.CFrame *= offsetCFrame
i cant tell if i did this wrong local oldOffset = CFrame.new() -- Don't edit this! local offset = viewmodel.Torso.CFrame:ToObjectSpace(viewmodel.Camera.CFrame) local viewmodelPos = camera.CFrame * attributes.offset viewmodel:PivotTo(viewmodelPos) -- (Optional): Accumulate the time in seconds t += dt -- Cancel out the offset we applied in the previous frame camera.CFrame *= oldOffset:Inverse() -- Apply the new offset camera.CFrame *= offset -- Store the offset we have applied so we cancel it in the next frame oldOffset = offset -- Update the offset that will applied! offset = CFrame.Angles(math.sin(t), 0, 0) --You can change this however you want! -- Proof (Optional): You can update the original cframe without affecting the offset camera.CFrame *= CFrame.new(math.sin(t)*10, 0, 0) --You can change this however you want!