> For the complete documentation index, see [llms.txt](https://csharp.progdocs.se/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://csharp.progdocs.se/annat/raylib/kollisioner.md).

# Kollisioner

## CheckCollisionRecs()

Tar emot två [Rectangles ](/annat/raylib/rectangle.md)som parametrar och returnerar true om de överlappar, false om de inte gör det.

```csharp
Rectangle playerRect = new Rectangle(5,5,10,10);
Rectangle enemyRect = new Rectangle(10,10,10,10);

bool areOverlapping = Raylib.CheckCollisionRecs(playerRect, enemyRect); // true
```

## GetCollisionRec()

Tar emot två [Rectangles](/annat/raylib/rectangle.md) som parametrar och returnerar en Rectangle som motsvarar överlappet mellan dem.

```csharp
Rectangle playerRect = new Rectangle(50,50,100,100);
Rectangle enemyRect = new Rectangle(100,100,100,100);
Rectangle overlap = Raylib.GetCollisionRec(playerRect, enemyRect);

Raylib.DrawRectangleRec(playerRect, Color.RED);
Raylib.DrawRectangleRec(enemyRect, Color.BLUE);
Raylib.DrawRectangleRec(overlap, Color.ORANGE);
```

![](/files/-MVNjKjAtFjx_GqmDAOd)

## CheckCollisionCircles()

Tar emot två [vektorer ](/grundlaggande/vektorer-numerics.md)som beskriver två cirklars mittpunkter, och två floats som beskriver cirklarnas radie, och returnerar true om de överlappar, false om de inte gör det.

```csharp
Vector2 playerPos = new Vector2(10,10);
Vector2 enemyPos = new Vector2(20,20);

// true
bool areOverlapping = Raylib.CheckCollisionCircles(playerPos, 10, enemyPos, 15);
```

## CheckCollisionCircleRec()

Tar emot en positions[vektor](/grundlaggande/vektorer-numerics.md) och en radie för en cirkel, och en [Rectangle](/annat/raylib/rectangle.md). Returnerar true om rektangeln och cirkeln överlappar varandra, false om de inte gör det.

```csharp
Rectangle playerRect = new Rectangle(5,5,10,10);
Vector2 enemyPos = new Vector2(20,20);

// true
bool areOverlapping = Raylib.CheckCollisionCircleRec(enemyPos, 15, playerRect);
```

## CheckCollisionPointRec()

Tar emot en punkt i form av en positions[vektor](/grundlaggande/vektorer-numerics.md) samt en [Rectangle](/annat/raylib/rectangle.md). Returnerar true om punkten befinner sig inuti rektangeln, false om den inte gör det.

```csharp
Rectangle enemyRect = new Rectangle(10,10,10,10);

mousePos = Raylib.GetMousePosition();

bool areOverlapping = Raylib.CheckCollisionPointRec(mousePos, enemyRect))
```


---

# 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, and the optional `goal` query parameter:

```
GET https://csharp.progdocs.se/annat/raylib/kollisioner.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
