# Hitta spelobjekt

{% hint style="info" %}
**OBSERVERA:** Detta bör inte göras mer än nödvändigt – alltså helst inte av många objekt samtidigt och helst inte varje frame. Det är systemmässigt kostsamt!
{% endhint %}

## Find

Find tar emot ett namn som parameter och returnerar det objekt som matchar. Om inget matchar, returneras null.

```
GameObject player = GameObject.Find("Player");
```

## FindWithTag

FindWithTag tar emot namnet på en tag som parameter och returnerar ett objekt som har taggen. Om inget matchar, returneras null.

```
GameObject player = GameObject.FindWithTag("StartPosition");
```

## FindGameObjectsWithTag

FindGameObjectsWithTag är en metod inbyggd i GameObject-klassen, som tar emot namnet på en tag som parameter och returnerar en array med de objekt som har taggen.

```
GameObject[] enemies = GameObject.FindWithTag("Enemy");
```


---

# Agent Instructions: 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://unity.progdocs.se/grundfunktioner/hitta-spelobjekt.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.
