function CalculateSteeringForPlane(plane ,--[[float]] dt, --[[Vector3]] targetPosition)
	-- Get current position and orientation of the plane
	local planePosition = vec3(getCarCoordinates(plane))
	local planeRotation = quat(getVehicleQuaternion(plane))

	-- Compute error vector transformed into local space
	local error = targetPosition - planePosition;
	error = -planeRotation * error;		--transform into local space				-- error = Quaternion.Inverse(plane.Rigidbody.rotation) * error;	  

	-- Normalize directional errors for pitch, roll, and yaw
	local errorDir		= error:normalize();
	local pitchError	= vec3(0, error.y, error.z):normalize();
	local rollError		= vec3(error.x, error.y, 0):normalize();
	local yawError		= vec3(error.x, 0, error.z):normalize();
	
	-- Initialize target input vector
	local targetInput	= vec3();

	-- Compute pitch based on error and thresholds
	local pitch = signedAngle(dir.forward, pitchError, dir.right);
	if (-pitch < pitchUpThreshold) then
		pitch = pitch + 360
	end
	targetInput.x = pitch;

	-- Determine steering adjustments for yaw or roll
	if (vec3.angle(dir.forward, errorDir) < fineSteeringAngle) then				-- if (Vector3.Angle(Vector3.forward, errorDir) < fineSteeringAngle) {
		-- Calculate yaw adjustment													--	   local yaw = Vector3.SignedAngle(Vector3.forward, yawError, Vector3.up);
		local yaw = signedAngle(dir.forward, yawError, dir.up);						--	   targetInput.y = yaw * yawFactor;
		targetInput.y = yaw * yawFactor												-- } else {
	else																			--	   local roll = Vector3.SignedAngle(Vector3.up, rollError, Vector3.forward);
		-- Calculate roll adjustment												--	   targetInput.z = roll * rollFactor;
		local roll = signedAngle(dir.up, rollError, dir.forward);					-- }
		targetInput.z = roll * rollFactor
	end

	-- Clamp inputs to range [-1, 1]
	targetInput.x = math.max(-1, math.min(1, targetInput.x))						-- targetInput.x = Mathf.Clamp(targetInput.x, -1, 1);
	targetInput.y = math.max(-1, math.min(1, targetInput.y))						-- targetInput.y = Mathf.Clamp(targetInput.y, -1, 1);
	targetInput.z = math.max(-1, math.min(1, targetInput.z))						-- targetInput.z = Mathf.Clamp(targetInput.z, -1, 1);

	-- Smoothly move towards the target input
	-- local input = Vector3.MoveTowards(lastInput, targetInput, steeringSpeed * dt);
	-- lastInput = input;

	return targetInput;
end

я переписал код изначально написанный для юнити.
вот оригинал
 Vector3 CalculateSteering(float dt, Vector3 targetPosition) {
        if (plane.Target != null && targetPlane.Health == 0) {
            return new Vector3();
        }

        var error = targetPosition - plane.Rigidbody.position;
        error = Quaternion.Inverse(plane.Rigidbody.rotation) * error;   //transform into local space

        var errorDir = error.normalized;
        var pitchError = new Vector3(0, error.y, error.z).normalized;
        var rollError = new Vector3(error.x, error.y, 0).normalized;
        var yawError = new Vector3(error.x, 0, error.z).normalized;

        var targetInput = new Vector3();

        var pitch = Vector3.SignedAngle(Vector3.forward, pitchError, Vector3.right);
        if (-pitch < pitchUpThreshold) pitch += 360f;
        targetInput.x = pitch;

        if (Vector3.Angle(Vector3.forward, errorDir) < fineSteeringAngle) {
            var yaw = Vector3.SignedAngle(Vector3.forward, yawError, Vector3.up);
            targetInput.y = yaw * yawFactor;
        } else {
            var roll = Vector3.SignedAngle(Vector3.up, rollError, Vector3.forward);
            targetInput.z = roll * rollFactor;
        }

        targetInput.x = Mathf.Clamp(targetInput.x, -1, 1);
        targetInput.y = Mathf.Clamp(targetInput.y, -1, 1);
        targetInput.z = Mathf.Clamp(targetInput.z, -1, 1);

        var input = Vector3.MoveTowards(lastInput, targetInput, steeringSpeed * dt);
        lastInput = input;

        return input;
    }


но в юнити другая система координат - направления отличаются от моих

local dir = {
    forward		= vec3(0, 1, 0),	-- вперед
    backward	= vec3(0, -1, 0),	-- назад
    right		= vec3(1, 0, 0),	-- вправо
    left		= vec3(-1, 0, 0),	-- влево
    up			= vec3(0, 0, 1),	-- вверх
    down		= vec3(0, 0, -1)	-- вниз
}

внеси в мой код изменения, которые адаптируют его под мою систему координат