SpawnPointer Class

Sets Multiplayer's spawn points on enabled, scene is loaded with Multiplayer.LoadScene, or SetAsSpawnPoint is called.

Definition

Namespace: AlterunaComponents
Assembly: Alteruna.Multiplayer.UnityFiles (in Alteruna.Multiplayer.UnityFiles.dll) Version: 1.0.0+c5328b35489e83c42e288435f5acf6115fd519e0
C#
public sealed class SpawnPointer : SpawnPointer
Inheritance
Object    Object    Component    Behaviour    MonoBehaviour    CommunicationBridge    SpawnPointer    SpawnPointer

Remarks

CommunicationBridge provides an easy way to get a reference of your MultiplayerManager and provides your class with methods used for possession. Unlike CommunicationBridgeUID, this component does not have a unique identifier (UID).

Example

C#
public class MyCommunicationBridge : CommunicationBridge
{
    private bool _isPossessed;
    private bool _isPossessor;
    private Avatar _avatar;

    // The Possessed method is called after awake and before start when the avatar is initialized.
    // When the user who possesses the object is the local player, isMe is true.
    public override void Possessed(bool isMe, User user)
    {
        // Since this method is called from a remote event, we know that the game object is possessed.
        _isPossessed = true;
        _isPossessor = isMe;

        // Inside CommunicationBridge, we can access the MultiplayerManager component through the Multiplayer property.
        // We can use it to get the avatar the given user possesses.
        _avatar = Multiplayer.GetAvatar(user.Index);
    }

    // When the player is removed from the game or the avatar is repossessed, we can manage it using
    // the Unpossessed method.
    public override void Unpossessed()
    {
        _isPossessed = false;
        _isPossessor = false;
        _avatar = null;
    }
}

Constructors

See Also