Check GameObject postion

Hello everyone,
I’m developing my first 2D game. It’s obviously very simple but since I’m new there i found some problems.
The game purpose is to dodge obstacles with your gameobject which can move left and right, i’m wondering how can I make the update method check if one obstacle occupy a position, for example when the rocket (obstacle) position is on (0, -4, 0), destroy the object and add +1 to the score. I didn’t found anything on internet so that’s why i’m asking that to you! hope you can help me, thank you in advance!

You can place Colliders in the scene that will call a function whenever a collision occurs. Unity Manual: Colliders

void OnTriggerEnter(Collider other) {
    Destroy(other.gameObject);
    UpdateScore();
}

You could also calculate the distance of the object and the position to determine a collision:

void Update()
{
    Vector3 collisionPosition = new Vector(0f, -4f, 0f);
    if (Vector3.Distance(this.transform.position, collisionPosition) < 1f)
    {
        UpdateScore();
        Destroy(gameObject);
    }
}

This code isn’t meant to work from a straight copy-paste, it’s to give you ideas.