How to check the position of the game object

I want to check if two gameobject’s X are the same then call a animation

But I don’t know how to use transform.position on a gameobject

Can someone help me?

You can access the transform of a gameobject by typing gameobject.transform.

A little example i like to use is OnTriggerEnter(Collider other); it runs code whrn a collider enters a trigger.

The gameobject that entered is other.gameobject.
The transform that entered is other.gameobject.transform.
The x position of the collider could be other.gameobject.transform.position.x.

private Transform transform = GetComponent();

private Vector3 position = transform.position;