How can i make accurate aiming on Viewmodel?

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 need to achieve that the Viewmodel moves that the camera would be exactly in place of the AimPoint

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


The video shows what is happening at the moment

local CURRENT_CAMERA_cf				= CAMERA.CFrame
	local WEAPON_cf_MULTIPLIERS 		= CurrSettings.CFrames
	local WEAPON_AIMPOINT_cf			= CurrSettings.AimPoint.CFrame or cf.new(0,0,0)--
	local MULTIPLED						= WEAPON_cf_MULTIPLIERS.ViewmodelMultiplier*WEAPON_cf_MULTIPLIERS.WeaponGripMultiplier
	
	local AIM_DIST						= WEAPON_AIMPOINT_cf:ToObjectSpace(CURRENT_CAMERA_cf)
	local AIM_OFFSET					= cf.new(AIM_DIST.X,AIM_DIST.Y,AIM_DIST.Z)

	if IsAiming then
		_CoreAndAimcf	= _CoreAndAimcf:Lerp(
			AIM_OFFSET,
			DELTA_TIME*15
		)
	else
		_CoreAndAimcf	= _CoreAndAimcf:Lerp(
			_Corecf,
			DELTA_TIME*8
		)
	end

	PointViewmodel(
		CURRENT_CAMERA_cf	--/ Fixated cf - camera
			*_CoreAndAimcf	--/ multiplier	- aim
			--*MULTIPLED			--/ advanced multipliers
	)

A piece of code responsible for positioning

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

I found an exactly similar post on DevForum from @serialeater (How do you make aiming on a viewmodel gun?), and his problem was solved. I repeated all the steps to solve his problem, but the end result was not successful.

Ill be grateful for any help, the main thing is that it works!

1 Like

You don’t need to individually input the key, just do this instaed cf.new(AIM_DIST)

How about doing something like this instead, but I’m not sure if it’s what you want, ignore the rest of the code its inside the RenderStepped:

local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera

local part = Instance.new("Part", workspace)
part.BrickColor = BrickColor.new("Really red")
part.Size = Vector3.new(0.2, 0.2, 0.2)
part.CanCollide = false
part.Anchored = true
part.Transparency = 0.8

RunService.RenderStepped:Connect(function()
	------------------------------------------------------------------------------
	local partCFrame = camera.CFrame:PointToWorldSpace(Vector3.new(0, 0, -2))
	local cameraCFrame = camera.CFrame:PointToWorldSpace()
	
	part.CFrame = CFrame.lookAt(partCFrame, cameraCFrame)
	------------------------------------------------------------------------------
end)
1 Like

it doesn’t work the way it should, anyway. It seems to me that there is no such problem, but it is visually created due to the holding animation, because during the animation the CFrame of AimPart does not change. If I’m wrong, please correct me

If that’s the case then just create an animation for ads(aim down sight).
Just download a plugin called camera locker so it locks on the dummy’s head when creating the animation.

1 Like

it seems to me that this is a very complicated and inefficient way to do viewmodel positioning.

Its not complicated really your just making an animation.

2 Likes