Angle between two objects vectors

Hi, I would like to ask how to get angle between two axes of two different gameobjects in 3D: between x-axis of the first object and x-axis of the second object.
I have tried several methods according to different instructions but without success.

Hello, your question is unfortunately somewhat unspecific.

Depending on whether you are looking for global or local alignment, or whether you also need an angle in a negative direction, the solution would look different, but if you are really only looking for the difference in angle on the global x-axis of two objects, while the other two axes are ignored, you could try this:

public Transform transformA;
public Transform transformB;

void Update()
{
    Quaternion a = Quaternion.Euler(transformA.eulerAngles.x, 0, 0);
    Quaternion b = Quaternion.Euler(transformB.eulerAngles.x, 0, 0);

    float deltaAngle = Quaternion.Angle(a, b);
    Debug.Log(deltaAngle);
}

Hi, you are right. One object is static in the scene and the other is grabbed by the user’s hand. The user comes to the (scene) object and tries to test alignment of the object his hand against the object in the scene. If the result angle (between both x axes) is less than a specified limit, the object in the hand will be colored. I’m currently working just on orientation comparison.

I really want to test just x axes and ignore others in my case.