When implementing rotation and Euler rotation simultaneously, the problem is that Euler rotation ne

Hello.

I press the icon on the mobile screen with my thumb and move it in the left and right (X-axis) directions to implement rotation in the plane of absolute coordinates (X-Z axis) and at the same time implement Euler rotation in the object’s relative coordinates (Z-axis).

                Vector2 moveDirection = moveActionToUse.action.ReadValue<Vector2>();
                float rotationDirection = moveDirection.x;
                transform.Rotate(0, rotationDirection * turnSpeed * Time.deltaTime, 0, Space.World);

                if(rotationDirection!=0)
                {
                    Quaternion localRotation = Quaternion.Euler(0f, 0f, -rotationDirection * turnSpeed * Time.deltaTime);
                    transform.rotation = transform.rotation * localRotation;
                }
                else if(rotationDirection == 0)
                {
                    Quaternion localRotation = Quaternion.Euler(0f, 0f, 0f);
                    transform.rotation = transform.rotation * localRotation;
                }

I want to do it. In the code above, if rotation and Euler rotation are performed at the same time, I want the Euler rotation to be restored to the zero value.

Help, please.

I want to see the full script please

using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.InputSystem;
using UnityEngine.Windows;
using static UnityEngine.GridBrushBase;

public class Player3 : MonoBehaviour
{
    private Rigidbody rb;
    public float speed;
    public float turnSpeed;

    [SerializeField] private InputActionReference moveActionToUse;

    void Awake()
    {
        rb = GetComponent<Rigidbody>();
    }

    void Update()
    {
         Vector2 moveDirection = moveActionToUse.action.ReadValue<Vector2>();
         float rotationDirection = moveDirection.x;
         transform.Rotate(0, rotationDirection * turnSpeed * Time.deltaTime, 0, Space.World);

         if(rotationDirection!=0) // How can I express here key press or drag icon??
         {
            Quaternion localRotation = Quaternion.Euler(0f, 0f, -rotationDirection * turnSpeed * Time.deltaTime);
            transform.rotation = transform.rotation * localRotation;
         }
         else if(rotationDirection == 0) // // How can I express here key press or drag icon??
         {
            Quaternion localRotation = Quaternion.Euler(0f, 0f, 0f);
            transform.rotation = transform.rotation * localRotation;
         }
                         
    void FixedUpdate()
    {
        if (rb != null)
        {
            rb.velocity = transform.forward * speed * Time.deltaTime;
        }
    }
}

I did Input system > Leftstick : Gamepad > Action Type : Value / Control Type : Vector2

Thank you

PS : Maybe I use crossicon with only settled X-Axis direction in mobile screen
How can I use Input system ?

Are you trying to rotate a dial onscreen with your mouse or finger??

Attached is my reference package for this. It uses old input but you can just swap out with the new input.

9648056–1372379–RotateZViaDrag.unitypackage (20.1 KB)