I tested and its almost what i want, i linked a place on the topic where you can understand more of what i am talking about
Im confused, a viewmodel is all that is posted in the testing place? Could you elaborate?
the “framework”, is the viewmodel
How is a viewmodel even related to animating the camera? Do you want us to show you how to animate the viewmodel or the camera?
its a little confusing to understand,
to explain better, go to this place:ICanIsmar Framework - Roblox
press 1 to get a weapon, fire it a couple times, reload, and look at the camera animations
try to think how that is made, you will probabbly get what i mean
Yeah, that is what I did in my post. I made it so that by animating the part you animate your camera…
Yeah, but for some reason your code is printing “Bad argument #2 (CFrame expected got nil)” in the
line “workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * newCamCF:ToObjectSpace(oldCamCF)”
Most likely because oldcamcf was never defined at the beggining(set it to the cams cf at the start) and that was stopping it every time before it could set oldcamcf
try that
Sorry for bringing this back up, but seems that it has a problem, the camera seems not to be tilting. I had a part rigged to torso for animating the head movement and use your code to make the camera follow the head’s orientation, here’s a test animation:
https://gyazo.com/83f1980d6717b64360dd4edcfe6761de
However when I run it in game, indeed the animation played, but the camera is “glitchy” and looks like it is attempting to rotate.
https://gyazo.com/dd78e8e6e500497d622833d4d7558b9c
Code:
local oldCamCF
function UpdateCamera()
if char.Torso.HeadCamera.Transform ~= CFnew( 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) then
local newCamCF = char.CamPart.CFrame:ToObjectSpace(char.Torso.CFrame)
if not oldCamCF then
cam.CFrame = cam.CFrame * newCamCF:ToObjectSpace(newCamCF)
else
cam.CFrame = cam.CFrame * newCamCF:ToObjectSpace(oldCamCF)
end
oldCamCF = newCamCF
end
end
runservice:BindToRenderStep("ReloadAnimation",1, function()
UpdateCamera()
end)
Any solutions to it? Thanks.
I also had this problem, seems like the camera does no tilt on the z axis
I think it’s possible to tilt on Z axis, or at least I hope it can, because I found a open source spring module which apply spring physics to the camera and it can set camera’s Z CFrame with the default Camera.
It uses the same approach to apply the CFrame:
I believe that p() is a function that returns an angle value:
local function updatecam()
local x,y,z
if cam.recoil.x and cam.recoil.x.p() then
x = cam.recoil.x.p()
else
cam.recoil.x = nil
end
if cam.recoil.y and cam.recoil.y.p() then
y = cam.recoil.y.p()
else
cam.recoil.y = nil
end
if cam.recoil.z and cam.recoil.z.p() then
z = cam.recoil.z.p()
else
cam.recoil.z = nil
end
if x or y or z then
cam.current.CoordinateFrame = cam.current.CoordinateFrame * CFrame.Angles(x or 0, y or 0, z or 0)
end
x,y,z = nil,nil,nil
end
game:GetService("RunService"):BindToRenderStep("RecoilCam",2000,function()
updatecam()
end)
https://gyazo.com/769daadb9e79ba915db9700f34ecab9a
Let me know if you want the full module to have a look, I hope this works for animating the camera as well…
Edit: There’s one more thing to notice about: This camera spring module overlay the Free Camera (Shift P)'s CFrame too, however the code provided up there will not, I guess this difference explains why Z can’t be tilted? But I still don’t know why they’re different.
https://gyazo.com/941e5b79d162c5344dcf21bf13c5664f
I somehow managed to fix it, you have to use ToOrientation() to find out the Z, this might not be the best solution but at least it works for me at the moment.
-- RenderStep
local newCamCF = char.CamPart.CFrame:ToObjectSpace(char.Torso.CFrame)
if oldCamCF then
--cam.CFrame = cam.CFrame * newCamCF:ToObjectSpace(newCamCF)
local _,_,z = newCamCF:ToOrientation()
local x,y,_ = newCamCF:ToObjectSpace(oldCamCF):ToEulerAnglesXYZ()
cam.CFrame = cam.CFrame * CFAngles(x,y, -z)
end
oldCamCF = newCamCF
I know that this post it’s old but you only need to use this
local offsetCFrame = Viewmodel.PrimaryPart.CFrame:ToObjectSpace(Viewmodel.FakeCamera.CFrame)
This script only works for rotation, you cannot move the camera
The code made my game much slower until I had to set the cadence of the bullets to 0.02
I need help with this…
What do you mean with CFAngles?
I’m having this issue too. I can find literally no fixes anywhere, and its kind of essential to making my game actually look good.
Try messaging instead of bumping a 2 year old thread.
He’s just simplified, but the original is CFrame.Angles()
chronically online
chars123456
it’s can not edit, can you open it?