# Worlds

## Worlds API

Worlds functionality can also be accessed through the `PlayResolver` just like rooms. Worlds work a differently however and are a bit simpler.

#### Worlds

First we need to fetch the available worlds. Unlike rooms, worlds cannot be created by a client and need to be setup in the developer portal.

```
async Task<(IReadOnlyList<WorldData>, bool)> FetchWorlds()
```

`FetchWorlds` in `PlayResolver.cs` allows us to fetch the available worlds for our project. This task returns a list of worlds in the form of `WorldsData` objects and a boolean that indicates if the operation was successful.

{% hint style="info" %}
This method also call `EnsurePlayConnection` which initializes the needed mechanisms in the`PlayResolver` if necessary. `EnsurePlayConnection` can also be called directly for initialization.
{% endhint %}

```
async Task<WorldData> FetchLocalWorld()
```

`FetchLocalWorld` in `PlayResolver.cs` returns the local world for a local running world server.

The `WorldsConnectDialog` populates a dropdown with the worlds returned by both of these methods so we can select a world.

After we've selected a world we can connect to it using:

```
void JoinWorld(IClient client,
                WorldData data,
                bool isSimulator = false)
```

`JoinWorld` in `PlayResolver.cs` connects the client that we pass to the method to the world we pass to the method.

The `isSimulator` optional parameter is used for simulators and can be ignored for regular client connections (see [Simulators](/0.7.4/simulators/simulators-overview.md)).

The `WorldsConnectDialog` is an example implementation for Worlds usage.


---

# 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://docs.coherence.io/0.7.4/api-reference/network-sdk/worlds.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.
