Realtime

Realtime is a component that manages your connection to a room, as well as any RealtimeViews that should be connected to the room’s datastore.

Editor Interface

App Key: This is a unique key used to track your apps usage. You can create one over on your account dashboard.

Join Room On Start + Room Name: If you would like Realtime to automatically connect to a room on Start, you can check this box and enter the room name here.

Note: Room names are namespaced to your App Key. Any room name used with a different App Key is considered a different room by the server.

Debug Logging: Our native plugin offers a more verbose logging mode. This can be useful when debugging low-level networking bugs. It’s rare that you will need to use this, but if you’re submitting a bug report to the Normal team, leave this turned on so we can properly diagnose the issue.

Network Statistics: The network statistics section shows you the current network statistics for the current connection. It includes things like packet loss %, bandwidth measurements, and the current room clock time.


Properties

Methods

Events

Property Definitions

int clientID

The ID of the local client on the server. If this client is not connected, this value will be -1.

Room room

A Room object that represents the data model for the room. This can be useful for getting the current room time that has been synchronized with the server. You can use this property to pass an instance of Room off to another instance of Realtime.

Method Definitions

void Destroy(GameObject gameObject)

This method destroys a prefab in the scene that has been instantiated using Instantiate(). It will destroy the prefab locally as well as on all remote clients.

gameObject: The root of the prefab. Note: You cannot destroy a child game object of a prefab.

void Destroy(RealtimeView realtimeView)

This method destroys a prefab in the scene that has been instantiated using Instantiate(). It will destroy the prefab locally as well as on all remote clients.

realtimeView: The RealtimeView at the root of the prefab. Note: You cannot destroy a child game object of a prefab.

GameObject Instantiate(string prefabName, bool ownedByClient=true, bool preventOwnershipTakeover=false, bool destroyWhenOwnerOrLastClientLeaves=true, Realtime useInstance=null)

Instantiates a prefab that has a RealtimeView at the root. Calling this method will lookup the prefab by name and instantiate it on all clients.

prefabName: The name of the prefab. (Make sure this prefab is in a Resources folder)

ownedByClient: A boolean that specifies whether this RealtimeView should automatically be owned by the creating client

preventOwnershipTakeover: A boolean that specifies whether other clients can RequestOwnership() of the RealtimeView on the root of this prefab

destroyWhenOwnerOrLastClientLeaves: A boolean that specifies whether to destroy this RealtimeView when its owner leaves the room, or if there is no owner, to destroy when the last client leaves.

useInstance: This is an optional parameter that you can use to specify which instance of Realtime to instantiate this prefab with. If you only have a single Realtime instance in the scene, this will be filled in automatically.

GameObject Instantiate(string prefabName, Vector3 position, Quaternion rotation, bool ownedByClient=true, bool preventOwnershipTakeover=false, bool destroyWhenOwnerOrLastClientLeaves=true, Realtime useInstance=null)

Instantiates a prefab that has a RealtimeView at the root. Calling this method will lookup the prefab by name and instantiate it on all clients. This method will automatically set the position and rotation of the prefab. If a RealtimeTransform component is present on the root, it will request ownership so the position and rotation are synchronized to all clients.

prefabName: The name of the prefab. (Make sure this prefab is in a Resources folder)

position: The world position to use when instantiating a prefab.

rotation: The world rotation to use when instantiating a prefab.

ownedByClient: A boolean that specifies whether this RealtimeView should automatically be owned by the creating client

preventOwnershipTakeover: A boolean that specifies whether other clients can RequestOwnership() of the RealtimeView on the root of this prefab

destroyWhenOwnerOrLastClientLeaves: A boolean that specifies whether to destroy this RealtimeView when its owner leaves the room, or if there is no owner, to destroy when the last client leaves.

useInstance: This is an optional parameter that you can use to specify which instance of Realtime to instantiate this prefab with. If you only have a single Realtime instance in the scene, this will be filled in automatically.

Event Definitions