-- Infinitely update the target position for the tank

currentElev = 0;
currentRot = 0;
while wait() do
	if (myMouse) then
		-- Position of mouse in world
		mousePoint = myMouse.Hit.p;
		
		-- Vector from tank to mouse point
		targetVector = (mousePoint - parts.GunBase.CFrame.p).unit;
		
		-- Determine where the gun should point
		targetRotations = determineNewDirections(targetVector);
		
		-- For each time we do all that math to determine the angle, we will smoothly rotate the gun towards it in 4 increments
		-- This means less lag (fewer calculations) but it's still smooth
		for i = 1, 4 do		
			newRotations = getSmoothRotation(targetRotations);
			setTurretDirection(currentElev, currentRot);
			wait();
		end
	end
end


