How i stay the rotate with joystick?

Hello I have a problem since when I move my UI joystick the character moves and rotates to the direction in which it moves but when you release the joystick the rotation returns to 0 I need the rotation to stay

sorry for my english i used Google Translate

void Update() {
     
     float angle = Mathf.Atan2(joystick.Vertical(), joystick.Horizontal()) * Mathf.Rad2Deg;
     transform.GetChild(0).rotation = Quaternion.Euler(new Vector3(0, 0, angle));
}

A quick change should make this work well enough to start:

Vector2 joy = new Vector2(joystick.Horizontal(), joystick.Vertical());

if(joy.sqrMagnitude > 0.001f)
{
	float angle = Mathf.Atan2(joy.y, joy.x) * Mathf.Rad2Deg;
	transform.GetChild(0).rotation = Quaternion.Euler(new Vector3(0, 0, angle));
}

Since it’s only necessary to change your facing while moving, you can check whether or not input is actively provided and work from there.