Find angle from velocity

I want to set angle based on gameobject velocity for 2d game. At present in game, object moves in correct direction but with wrong angle. If I can able to set angle from its velocity then my problem is solved but I can’t able to find solution for that.

I already used google for this purpose but didn’t find any useful content. Please give me some suggestion in this.

Maybe you can use something like:

 Vector2 dir = rigidbody.velocity;
 float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
 transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

This works like a transform.LookAt() for 2D.

let’s say the if velocity = 0 than angle = 0 else if velocity = maxSpeed than angle = maxAngle:

transform.eulerAngles.z = (rigidbody.velocity.magnitude / maxSpeed) * maxAngle;