Help with CFrames

Soo, i made a Viev Model, you can aim with it, but the problem is that AimPart (part to which gun teleports) is not precise, this mean i need to move it to make player aim in good spot

Note: I used EgoMoose’s code for lerping and adjusted offset to my system

  • State is true/false depending on input
  • Tool.Part1 is tool’s handle
  • Tool.Part0 is VievModel’s Torso
  • VievModel’s primary part is his head

Code:

local offset = ((CurrentViewModel.Tool.Aim.CFrame:Inverse() * CurrentViewModel.Tool.Handle.CFrame):Inverse() * CurrentViewModel.VievModel.Torso.Tool.C1) -- here is problem
	
	
	local start = CurrentViewModel.VievModel.Torso.Tool.C0
	local goal = state and offset or CFrame.new()

	aimCount = aimCount + 1
	local current = aimCount
	for t = 0, 101, 10 do
		if (current ~= aimCount) then break end
		game:GetService("RunService").RenderStepped:Wait()
		CurrentViewModel.VievModel.Torso.Tool.C0 = start:Lerp(goal, t/100)
	end

This is better visualization of what i mean


IDK how i can fix this, can anyone help?

After long time, i found out that the main problem was Offset itself, see offset should be different on different axis, soo at the end i added new CFrame with specific multiplication of original offset that worked to Tool’s Motor6D C0 (which was Torso CFrame) and it works now

1 Like

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