> For the complete documentation index, see [llms.txt](https://hopemoore.gitbook.io/coding-for-creatives/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hopemoore.gitbook.io/coding-for-creatives/glossary/objects-classes-and-libraries/untitled.md).

# Accessing Objects

Each language has its own way of creating objects, but generally have the same way of accessing aspects of objects.

Generally, it's with dots and it starts with the largest object or class and gets smaller each time.

**Example:** if we had Census data to access from outside of a USPopulation object and we wanted the name of the head of household of 101 N. Court Street.

USPopulation.Midwest.Ohio.Southeast.Athens.Athens.UpTown.NorthCourtStreet.0-300.100.Household.Head.name

Each dot is looking deeper into the object until we get what we want - usually a value or a function related to it.

**Examples of where we've used it before in class:**

Seeing if the space bar is pressed:

```csharp
if (Input.GetKeyDown(KeyCode.Space) == true)
{

}
```

**Input** is a class and we use the dot to access the class' **GetKeyDown()** function.

**KeyCode** is not a class, but is similar, proving the key code for Space.

```csharp
gameObject.transform.position.y
```

If we have access to a game object in Unity, we can dig deeper and get to its Transform component, then into its position property, and then its position on the y-axis.

```csharp
gameObject.GetComponent<SpriteRenderer>().sprite
```

In Unity, we can access any Component on a game object using GetComponent\<NameOfComponent>() and then a dot to go into the component to access its variables and functions.

```csharp
public void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.name == "Ground")
    {
    }
}
```

When a function provides information such as a Collision2D type here named collision, we can use it to access the game object and all its features.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hopemoore.gitbook.io/coding-for-creatives/glossary/objects-classes-and-libraries/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
