-
Notifications
You must be signed in to change notification settings - Fork 2
Home
SimonAlteruna edited this page Dec 23, 2022
·
27 revisions
Primary namespace for Alteruna Multiplayer
| AttributesSync | Synchronize methods and fields using attributes. |
| AttributesSync.SynchronizableField | Synchronise target field. |
| AttributesSync.SynchronizableMethod | Synchronise target Method. |
| Avatar |
Avatar is used to represent a player in a Room.
Avatars have events that can be used similar to OnEnable and OnDisable. The possession status can also be accessed with C# // Avatar reference
public Avatar MyAvatar;
void Awake() {
// Event for avatar possessed
MyAvatar.OnPossessed.AddListener(Possessed);
// OnUnpossessed is called on unposses and client disconnect.
}
// Log username on Possession
void Possessed(User user) => Debug.Log("Possessed by " + user.Name);When working with Avatars, the most useful information is to check for the controlled Avatar, this can be done using C# public Avatar MyAvatar;
void Awake() {
MyAvatar.OnPossessed.AddListener(Possessed);
}
void Possessed(User user) {
// Return if not user's client.
if (!user.IsMe) return;
// Set camera as child to object
Camera myCamera = Camera.main;
myCamera.transform.position = transform.position + new Vector3(0, 0.4f, 0);
myCamera.transform.SetParent(transform);
// Lock cursor
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
} |
| Bucket | Class Bucket is a collection of players used to define NetLOD behaviour. |
| BucketBehavior | |
| CommunicationBridge | |
| CommunicationBridgeUID | Holds references and methods for communications with active Multiplayer and UID components. |
| Encryption | |
| Endpoint | |
| InputSynchronizable | Synchronize inputs (255 buttons and 255 axis maximum) The input vales will update on this and other clients simultaneously.
Sync inputs and move transform based on those inputs. Note that this does not sync position, after a while the positions could become unsynced. C# using UnityEngine;
using Alteruna;
public class SyncedPlayerMovement : MonoBehaviour
{
//reference to a InputSynchronizable object in the scene with a avatar.
public InputSynchronizable InputSync;
public float Speed = 5;
private void Start() {
InputSync.AddAxis(new[] {"Horizontal", "Vertical"});
}
private void Update() {
float scaledSpeed = Speed * Time.deltaTime;
transform.Translate(
scaledSpeed * InputSync.AxesValues[0],
scaledSpeed * InputSync.AxesValues[1],
0);
}
} |
| InterpolationTransformSynchronizable | |
| Multiplayer | The component Multiplayer gives access to all functionality and communication for Alteruna Multiplayer. |
| NameGenerator | Class NameGenerator generates names from a random animal and adjective. |
| ProcedureParameters | Parameters containing data to be sent together with Remote Procedure Calls. |
| Reader | Class Writer is used to write data to be sent to other Users through a Synchronizable. |
| Rigidbody2DSynchronizable |
Rigidbody2DSynchronizable is a Synchronizable that synchronizes the state of a Rigidbody2D component. |
| RigidbodySynchronizable |
RigidbodySynchronizable is a Synchronizable that synchronizes the state of a Rigidbody component. |
| Room | |
| Service | |
| ServiceState | |
| Spawner | Class Spawner defines a component which can instantiate and destrot objects on all clients in the Room simultaneously. |
| SyncedAxis | Alternative way of implementing InputSynchronizable. |
| SyncedKey | |
| Synchronizable | Class Synchronizable defines a base containing data to be synchronized with other clients in the Room. Synchronizable also support attributes, but unlike AttributesSync, it does not auto commit changes in fields marked with the |
| Synchronizable.SynchronizableField | Synchronise target field. |
| Synchronizable.SynchronizableMethod | Synchronise target Method. |
| TransformSynchronizable | Class TransformSynchronizable defines a component which synchronizes its gameobjects transform with other clients in the Playroom. |
| UniqueAvatarChild | Instantiate a prefab as a child from a array. If avatar index goes beyond the lenght of the array, it will loop. |
| UniqueAvatarColor | Change Hue to a unique color based on avatar index. |
| UniqueID | Class UniqueID defines an application-wide unique ID for identifying objects to be synced between Users in a Room. |
| UnityLog | Class UnityLog is responsible for logging internal messages and events. |
| UnityReader | Class UnityReader is used to write Unity types to a Reader. |
| UnityWriter | Class UnityWriter is used to write Unity types to a Writer. |
| User | User class containing index and name. |
| UtcTime | Useful time related fields using global time. Note that its its common for the system time to be inaccurate, expect a difference by 5 seconds. If the machine time is not automatically updated, it can be up to much more. |
| Writer | Class Reader is used to read data recieved from another User. |
| IInput | |
| IServiceListener | |
| IServiceStateListener |
| RemoteProcedure | |
| RemoteProcedureAck | |
| RemoteProcedureReply |
| InterpolationTransformSynchronizable.InterpolationMethodType | |
| InterpolationTransformSynchronizable.LocalBehaviourType | |
| SyncedKey.KeyMode | Key behavior mode |
| UserId | User Indexes to target multiple users. |