How would i make my gun aim smoother

if not inAim then
  inAim = true
  local tween = Tweenservice:Create(camera, info, {CFrame = usedVM.Gun.Aim.CFrame})
  tween:Play()
end

This kinda works, but for like .1 second and it just snaps back.
https://gyazo.com/b48b6eb9fd63cc033f533253baf6a10d

Try this, I’ve changed the way you handled the m2 variable and a few other things that could be relevant to the issue:

local m2 = false

rs:BindToRenderStep("Viewmodel", Enum.RenderPriority.Camera.Value + 1, function()
	if not tool then
		return
	end

	if char:FindFirstChildWhichIsA("Humanoid").Health <= 0 then
		if camera:FindFirstChild(tool.Name) ~= nil then
			workspace.Camera:FindFirstChild(tool.Name):Destroy()
		end
	end

	if equipped then
		if camera:FindFirstChild(tool.Name) ~= nil then
			local usedVM = camera:FindFirstChild(tool.Name)
			local delta = uis:GetMouseDelta()
			local x = clamp(delta.X, -.2, .2)
			local y = clamp(delta.Y, -.2, .2)
			local m2 = false
			local targetCf = usedVM.Gun.Aim.CFrame
			
			swayCF = swayCF:Lerp(cfNew(x, y, 0), .02)
			usedVM:PivotTo(camera.CFrame * swayCF)

			if aiming then
				--camera.CFrame = usedVM.Gun.Aim.CFrame
				camera.CFrame = camera.CFrame:Lerp(targetCf, 0.05)
			end
		end
	end
end)

uis.InputBegan:Connect(function(input, gc)
	if not gc then
		if input.UserInputType == Enum.UserInputType.MouseButton2 then
			m2 = true
		end
	end
end)

uis.InputEnded:Connect(function(input, gc)
	if not gc then
		if input.UserInputType == Enum.UserInputType.MouseButton2 then
			m2 = false
		end
	end
end)

Same thing still happens.
https://gyazo.com/202ff42ee71ddf903241ac9075c47c1f

That’s strange, when I tested it on studio it worked fine. You said that Tweening worked to some extent for you before I had sent the message, what was info?
https://gyazo.com/10e62fac9a3fb1a043622364e2e7212d.mp4

HI,
Info is: local Info = TweenInfo.new( .3, Enum.EasingStyle.Cubic )

Try remove if not inAim then and see if it works

No,
Reason is that it will keep playing the tween.
How do i know? I tried already.

Im clueless, i have 0 ideas.

If you want to use :lerp then you will have to use the gun and cameras current position in the lerp not the starting position as that as you demonstrated will just make the gun/camera move a bit also whilst I am here for the lerps alpha value make sure to properly adjust for delta time like so:

1-1/(dt*alpha+1)

I really dont care how i would make it, if it works, it works.

Im gonna try it out now.

Thanks for sugesting

camera.CFrame = camera.CFrame:Lerp(goal, 1-1/(dt*300+1))

makes it look like this: https://gyazo.com/c0b8f7c730302c729626b6ab55dd9f40

You multiplied dt by 300 of course its gonna snap instantly you want to divide it in this case.

Then it wouldent even move like 1 pixel dude.
camera.CFrame = camera.CFrame:Lerp(goal, 1-1/(dt*2+1))

Here: https://gyazo.com/ab516468c6011c85ca3fa5dcc59deff0

What do you recommend that the alpha should be? I play on 240 fps btw

the fps shouldnt effect anything did you lerp from the starting position or from where the gun currently is?

Let me break down how the viewmodel is thrown together:

Its this:

image

The aim part is in the red circle. And yes it orientated correctly.

Then i throw the viewmodel in replicated storage.

I dont understand. The starting point from the camera?

Code: camera.CFrame = camera.CFrame:Lerp(goal, 1-1/(dt*2+1))

Oh yeah, it contains a head, which basically sets it to the cameras CFrame

omg those arms anyway after checking the code sample you sent me it looks like you scripted it correctly maybe try lerping the heads position as you mention that is related to the camera.

Yo lets go???

local aimPart = usedVM.Gun.Aim
			local head:Part = usedVM:FindFirstChild("Head")
			local goal = aimPart.CFrame
			
			if m2 then
				--camera.CFrame = usedVM.Gun.Aim.CFrame
				
				head.CFrame = head.CFrame:Lerp(goal, 1-1/(dt*6+1))

Video: https://gyazo.com/20ddc66e54aa4c76079e621b3615eddc

Looks good maybe try increasing the multiplier on deltatime to make it a little more snappy?
Also what does leaving aim down sights look like as you need to add the lerp to both aiming down sights and un aiming down sights

I will make going out of it later, im trying to fix the ads rn

1 Like

yoooo, thanks a bunch.

Finished result: https://gyazo.com/3375cbcf4ea2102bed3b690e39c79476
Im happy with the result and im thankfull for everyone contributing to this topic.

Thanks again.

1 Like