calculate angle between 2 gameobjects and rotate in unity code example
Example: check the angle between two game objects unity
Vector3 dir = GameObject1.position - GameObject2.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
Vector3 dir = GameObject1.position - GameObject2.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;