I’m in the process of creating an FPS shooter, my current state of progress is;
The ADS feels sticky and blocky, I’d rather like my ADS to look like this instead;
However, the issue I run into it when I do so is with character movement.
You can see the gun lags behind the character, due to it not being updated frequently enough.
My code consists of-
`local function gunEquip_FUNC()
user_PLAYER.CameraMode = Enum.CameraMode.LockFirstPerson
UserInput_SERVICE.MouseIconEnabled = false
characterRender_CON = Run_SERVICE.RenderStepped:Connect(characterRender_FUNC)
end`
- When ADS doesn’t lag behind.
`local function characterRender_FUNC()
local gunDir_CF, pos_V3, camDir_CF
local function renderingCF(fetch_CF, lerp_INT)
pos_V3 = fetch_CF.p
camDir_CF = (fetch_CF - (fetch_CF.p))
gunDir_CF = gunRoot_PART.CFrame - gunRoot_PART.CFrame.p
gunDir_CF = gunDir_CF:lerp(camDir_CF, lerp_INT)
end
if ads_BOOLEAN then
local render_CF = ((user_CAMERA.CFrame) - (user_CAMERA.CFrame.UpVector*aim_ATTACHMENT.Position.Y) + (user_CAMERA.CFrame.LookVector*aim_ATTACHMENT.Position.Z) - (user_CAMERA.CFrame.RightVector*aim_ATTACHMENT.Position.X))
renderingCF(render_CF, .1)
gunDir_CF = CFrame.fromMatrix(Vector3.new(), gunDir_CF.XVector, camDir_CF.YVector, gunDir_CF.ZVector)
- When ADS lags behind.
`local function characterRender_FUNC()
local gunDir_CF, pos_V3, camDir_CF
local function renderingCF(fetch_CF, lerp_INT)
pos_V3 = fetch_CF.p
local gunPos_V3 = gunRoot_PART.Position
pos_V3 = gunPos_V3:lerp(pos_V3, lerp_INT)
camDir_CF = (fetch_CF - (fetch_CF.p))
gunDir_CF = gunRoot_PART.CFrame - gunRoot_PART.CFrame.p
gunDir_CF = gunDir_CF:lerp(camDir_CF, lerp_INT)
end
if ads_BOOLEAN then
local render_CF = ((user_CAMERA.CFrame) - (user_CAMERA.CFrame.UpVector*aim_ATTACHMENT.Position.Y) + (user_CAMERA.CFrame.LookVector*aim_ATTACHMENT.Position.Z) - (user_CAMERA.CFrame.RightVector*aim_ATTACHMENT.Position.X))
renderingCF(render_CF, .1)
gunDir_CF = CFrame.fromMatrix(Vector3.new(), gunDir_CF.XVector, camDir_CF.YVector, gunDir_CF.ZVector)
lerp int is .35 if anyone has a question about that.
it’s calculated as
gunRoot_PART.CFrame = gunDir_CF+pos_V3