Unit placement system isnt centered

https://gyazo.com/3e8ead0dd7787c33c4ba75701a6f7ff2
The unit isn’t centered at the mouse, and only slightly above

local mousePos = Vector2.new(mouse.X, mouse.Y)

			local ray = camera:ViewportPointToRay(mousePos.X, mousePos.Y, 5)
			local result = workspace:Raycast(
				ray.Origin,
				ray.Direction * 500,
				params
			)

			if result then
				local targetPos = result.Position + Vector3.new(0, bottomOffset, 0)

				if lastPos then
					local delta = targetPos - lastPos.Position

					local targetTiltX = delta.Z * 40 * 2
					local targetTiltZ = delta.X * -40 * 2

					tiltX += (targetTiltX - tiltX) * dt * 5
					tiltZ += (targetTiltZ - tiltZ) * dt * 5
				end
				
				lastPos = CFrame.new(targetPos)
				
				emptyAoE.Position = result.Position
				underVFX.Position = result.Position

				local cf =
					CFrame.new(targetPos)
					* CFrame.Angles(math.rad(tiltX), 0, math.rad(tiltZ))

				unitModel:PivotTo(cf)
			end

Afaik, for the player’s camera you need to use ScreenPointToRay instead of ViewportPointToRay

2 Likes