I need help in understanding this: room.transform.position.x

room.transform.position.x

The room is a simple room of 2D objects and this script is attached to my player which is constantly moving in x direction.
I need to understand that the room is not moving then how are we using transform ?

The whole code is as follows, just in case

foreach (var room in currentRooms)
    {

        float roomWidth = room.transform.Find("Collider").localScale.x;
        float roomStartX = room.transform.position.x - (roomWidth * 0.5f);
        float roomEndX = roomStartX + roomWidth;}

Thanks in advance !

Good day, in this code you are just storing 3 values

roomWidth is the X axis lenght of the room collider component

roomStartX is equal to (position in X axis of the room - (roomWidth * 0.5))

roomEndX is equal to roomStartX + roomWidth

Whats your question then? you are not moving anything.

For your question i think you are little new here. Transfomr is the basic component for ALL objects in the scene, it contains the position, the rotation and the scale.

when you access transform it can be for read some value or for change some value. In this script, it only reads values.

another diferent thing (like changing the position) would be something like:

room.transform.position = new Vector3 (23, 8, 0);

But it is not the case!

Goodbye!