Recoil Camera Y Axis Error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I am creating recoil.

  1. What is the issue? Include screenshots / videos if possible!

When I shoot the gun, and the recoil function fires, it snaps my camera instead of making my camera go up

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried, but none of the recoil were helpful.

I want a basic recoil that moves the cameras orientation up by the settings recoil value.

local function recoil()
	local Camera = game.Workspace.CurrentCamera
	local r = Camera.CFrame.Rotation
	Camera.CFrame = CFrame.Angles(r.X,r.Y+Config.Recoil.Value,r.Z)  
end
2 Likes

What exactly is the issue? The way it rotates to the side rather than rotating up?

1 Like

My camera doesnt recoil, instead it snaps to 0,0,0 posititon

2 Likes
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

local RECOIL_AMOUNT = 1

local function recoil()
	camera.CFrame = camera.CFrame * CFrame.Angles(math.rad(RECOIL_AMOUNT), 0, 0)
end

Try this perhaps? Sorry, I’m not the best with cframes so I cant really explain why yours wasn’t working. However, testing this code in my own place made the camera rotate “upwards” every time the function was called. Use lerping to smooth it out.

2 Likes

sdf jsnfhdnsjffbdfbdjfbsdfjfjhfbsdjkfbsdjkfbjkfsbhkfdsfbhsjfbauyvtbgu3gy53t478952783537896y78 b3478rfwy 78fy78dtf78sat fa78f t78at78g78f y678y6r578 y7e89f y8 4897347t5234785n287y789v2747823894 f79fv7e7d7g78we78fags78dfa8yg8dfg67bn 4w57eu89aufhy 8edhoawo9ghsd89sag9gy9yw89e4yt9ay894y89089036y4y89 89 4

1 Like

Yes this worked thank you for helping me

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.