i have a really cool recoil system that’s supposed to tilt the camera, and then recover
both of these actions are lerped
this is what the final product is supposed to look like
(i’m setting the cframe directly in the video, so camera movement is entirely blocked)
in order to allow mouse movement while lerping the camera, i need to do:
camera.CFrame *= offset
, NOT camera.CFrame = CFrame.new(camera.CFrame.Position) * offset
, because the second option is setting the cframe directly, which blocks camera movement
i’m actually struggling to get this to work, because i can’t just multiply Rotation
of CFrame, since it’s read-only, and multiplying the CFrame by the offset directly just does this:
i very much need help, yes i very much tried using ai
local function ApplyRecoil(recoilStrength: CFrame)
local recoilTweak: NumberValue = utility.GetGameplayValue('recoilTweak')
local tiltDuration = 0.15
local recoveryDuration = 0.25
local elapsed = 0
local applying = true
-- totally not ai generated code
local axis, angle = recoilStrength:ToAxisAngle()
angle = angle / recoilTweak.Value
local initialRotation = camera.CFrame - camera.CFrame.Position
local targetRotation = initialRotation * CFrame.fromAxisAngle(axis, angle)
rService:BindToRenderStep('Recoil', Enum.RenderPriority.Camera.Value, function(deltaTime)
elapsed += deltaTime
local alpha
local currentRotation
if applying then
alpha = math.clamp(elapsed / tiltDuration, 0, 1)
currentRotation = initialRotation:Lerp(targetRotation, alpha)
if alpha >= 1 then
applying = false
elapsed = 0
end
else
alpha = math.clamp(elapsed / recoveryDuration, 0, 1)
currentRotation = targetRotation:Lerp(initialRotation, alpha)
if alpha >= 1 then
rService:UnbindFromRenderStep('Recoil')
end
end
camera.CFrame *= CFrame.Angles(math.rad(15), 0, 0) -- pretend currentRotation is here
end)
end
i am open to literally everything