Hello iam working on a game wich is pretty simple in the middle of the screen is a stick wich you can tilt by using the keys a and d and now i want to replace the keys with two ui buttons.

public class RotateSkript : MonoBehaviour
{
public int speed;
void Start()
{
speed = 180;

    }

    void Update()
    {

        //GetAxis("Horizontal")

        if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0)
        {
            
            float turnSpeed = speed * Time.deltaTime;
            
            float rotate = Input.GetAxis("Horizontal") * turnSpeed;
           
            float currentRotation = gameObject.transform.rotation.eulerAngles.z;
            
            Quaternion rotation = Quaternion.Euler(0, 0, currentRotation + rotate);
            
            gameObject.transform.rotation = rotation;
        }
    }

},

Hello.

Now, you have all the movement inside the Update, but is only activating when GetAxis Horiz is differrnt to 0.

Unity uses this "GetAxis to detect typical Movement keys, like the arrows.

Now you will need to create your movement funcitons and assign that functions to the buttons

Learn about this, watch tutorials, try try and you will get it.

code should finish like:

void MoveToright()
{
float turnSpeed = speed * Time.deltaTime;
             
float rotate = 1 * turnSpeed;
            
float currentRotation = gameObject.transform.rotation.eulerAngles.z;
             
Quaternion rotation = Quaternion.Euler(0, 0, currentRotation + rotate);
             
gameObject.transform.rotation = rotation;
}

void MoveToright()
{
float turnSpeed = speed * Time.deltaTime;
             
float rotate = -1 * turnSpeed;
            
float currentRotation = gameObject.transform.rotation.eulerAngles.z;
             
Quaternion rotation = Quaternion.Euler(0, 0, currentRotation + rotate);
             
gameObject.transform.rotation = rotation;
}

BYEE!