CREATE YOUR WORLD
Multiplay

Multiplay Room State

8min
Document image


Multiplay Room provides a State property for managing connected player or object location.

State's data definition be managed from the Schema file, which is below the multiplay package. The onStateChange event is first called when the client successfully establishes a connection to the room, and is afterwards called whenever there are changes to the state data.

Server API

API

Description

state.SCHEMA_NAME

You can access the SCHEMA_NAME field defined in the schema file with state. You can modify the field value at a request from a client or internal server logic. The changed state is then automatically propagated to the clients using the OnStateChange event.

📘 Please refer to the following guide. [ZEPETO.Multiplay(Server) API]

TypeScript


API

Description

room.OnStateChange(State, isFirst)

You can register a state change callback when you join the room. You can receive the state of the entire room for the first time, and only the changed state will be received afterwards.

Client API

TypeScript




Define Schema file

Schema is a data structure for defining the current state in the room. Rooms are primarily used to manage player information, player or object locations, etc.

To edit a schema, you can select Project View → MultiplayPackage Asset → schema.json, and then modify the data type to use for the World in the Inspector window. You can modify the data type to use for the World in the Inspector window.

STEP 1 : Defining Schema Types

Scheme Types is the Data Structure used in the World. In the Inspector → Schema Types, press the [+] button and add data.

4-4-3-1.gif
4-4-3-1.gif




STEP 2 : Add Room State

The Room State is the Property that shows the current status of the World Room, and is expressed in the Schema structure as defined above.

Among the Schema Types, select the typeRoom State that will be used as the current status of the World and set it as the SCHEMA_NAME.

Document image


Schemas.json Example

JSON