Rotate sprite on the Z axis with Virtual Joystick (from Joystick Pack) [2D]

I’m trying to rotate a sprite on the Z axis with the use of a Virtual Joystick from the “Joystick Pack Free” asset. I’m using the code below but it doesn’t work as I want to.

transform.eulerAngles = new Vector3(0, 0, joystick.Horizontal * joystick.Vertical * -160);

This script is part of the sprite, and joystick is a public Joystick.

I tried this code too:

transform.eulerAngles = new Vector3(0, 0, (Mathf.Atan(joystick.Vertical / joystick.Horizontal)) * -45);

Neither or which works. I tried with many values but it doesn’t seem to work.

Thank you for the help.

i have same problem lmaooome is dumb

I solved the problem by myself using this code:

if (joystick.Vertical < 0)
{
    transform.eulerAngles = new Vector3(180, 0, joystick.Horizontal * -90);
}
else
{
    transform.eulerAngles = new Vector3(0, 0, joystick.Horizontal * -90);
}

A simpler version would be this:

Vector2 dir = new Vector2(joystick.Vertical, joystick.Horizontal);
transform.LookAt(Vector3.forward, dir);

For 3d it would be this:

Vector3 dir = new Vector3(joystick.Vertical, 0f,  joystick.Horizontal);
transform.LookAt(dir);

How would you change the values to make the player flip at the x axis?