unity get rotation between two vectors code example

Example 1: unity rotation between 2 points

transform.rotation = Quaternion.FromToRotation(Vector3.up, v3Pos2 - v3Pos1);

Example 2: get angle between two vectors unity

Vector3 targetDir = target.position - transform.position;
float angle = Vector3.Angle(targetDir, transform.forward);

Example 3: 2 rotation unity

// Rotation scripting with Euler angles correctly.
// Store the Euler angle in a class variable, and only use it to
// apply it as a Euler angle, but never rely on reading the Euler back.
        
float x;
void Update () 
    {
        x += Time.deltaTime * 10;
        transform.rotation = Quaternion.Euler(x,0,0);
    }