Exact Character Position for Camera Attachment

Hello, everyone!

I am in need of assistance. I am currently making a camera system to work with some first-person guns. The guns work well, however, I get this pesty stuttering when walking which I believe is from animations and the way my camera system works to provide realism.

My camera system attaches the camera to the head which moves up and down to simulate head bobbing while walking with an R15 animation.

My question, in short, is how can I get the exact, unmoving (y axis) coordinates, to cframe the camera too while the gun is equipped. Similar to how camera subject can be put as the humanoid and it will grab the “humanoids position”. I’ve tried attaching the camera to the humanoid root part, I however still suffer from the jittering. I am able to remove stuttering all together by using Roblox’s default camera script, that is, however, not ideal for my use case so I am trying to stay away from using it.

Here is a snippet of my code, note that when SeeChar.Value == false means a gun is equipped and it will turn all body parts to invisible and non-collideable to prevent clipping.

if script.SeeChar.Value == false then
			
				humanoidpart.Parent.Humanoid.AutoRotate = false
				cam.CoordinateFrame = CFrame.new(character.HumanoidRootPart.Position + Vector3.new(0,1.5,0))
				* CFrame.Angles(0,math.rad(AngleY),0) 
				* CFrame.Angles(math.rad(AngleX),0,0)
				* CFrame.new(0,0.5,-0.35) -- offset
			else
				
				humanoidpart.Parent.Humanoid.AutoRotate = true
				cam.CoordinateFrame = CFrame.new(character.Head.Position)
				* CFrame.Angles(0,math.rad(AngleY),0) 
				* CFrame.Angles(math.rad(AngleX),0,0)
				* CFrame.new(0,0.5,-0.35) -- offset
				camPos = cam.CFrame
			end

Here’s a quick example of what I mean by the stuttering: https://gyazo.com/a9a7e2ff555fd66a649eb2b19c2b4a85?token=a7b7d08e64d017a1ae213765e9dcdb84

Help would be greatly appreciated!

1 Like