Open 3D Engine Multiplayer Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Multiplayer::SimplePlayerSpawnerComponent Class Reference

A network player spawner. Attach this component to any level's root entity which needs to spawn a network player. If no spawn points are provided the network players will be spawned at the world-space origin. More...

#include <SimplePlayerSpawnerComponent.h>

Inherits AZ::Component, Multiplayer::IMultiplayerSpawner, and Multiplayer::ISimplePlayerSpawner.

Public Member Functions

 AZ_COMPONENT (Multiplayer::SimplePlayerSpawnerComponent, "{0A6D0132-3FD2-4F13-B537-2B1DA99E34E9}")
 
AZ::Transform GetNextSpawnPoint () const override
 
const AZStd::vector< AZ::EntityId > & GetSpawnPoints () const override
 
uint32_t GetSpawnPointCount () const override
 
uint32_t GetNextSpawnPointIndex () const override
 
void SetNextSpawnPointIndex (uint32_t index) override
 Overwrites the next joining player's spawn index. The spawn index provided must be a valid (in-bounds) index into the array of available spawn points.
 
- Public Member Functions inherited from Multiplayer::IMultiplayerSpawner
 AZ_RTTI (IMultiplayerSpawner, "{E5525317-A476-4209-BE45-477FB9D96083}")
 
virtual Multiplayer::NetworkEntityHandle OnPlayerJoin (uint64_t userId, const Multiplayer::MultiplayerAgentDatum &agentDatum)=0
 
virtual void OnPlayerLeave (Multiplayer::ConstNetworkEntityHandle entityHandle, const Multiplayer::ReplicationSet &replicationSet, AzNetworking::DisconnectReason reason)=0
 
- Public Member Functions inherited from Multiplayer::ISimplePlayerSpawner
 AZ_RTTI (ISimplePlayerSpawner, "{6DAC5CDE-5D63-4C0B-9F7B-9F5B09079DBB}")
 
virtual AZ::Transform GetNextSpawnPoint () const =0
 
virtual const AZStd::vector< AZ::EntityId > & GetSpawnPoints () const =0
 
virtual uint32_t GetSpawnPointCount () const =0
 
virtual uint32_t GetNextSpawnPointIndex () const =0
 
virtual void SetNextSpawnPointIndex (uint32_t index)=0
 Overwrites the next joining player's spawn index. The spawn index provided must be a valid (in-bounds) index into the array of available spawn points.
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
static void GetProvidedServices (AZ::ComponentDescriptor::DependencyArrayType &provided)
 
static void GetIncompatibleServices (AZ::ComponentDescriptor::DependencyArrayType &incompatible)
 

Protected Member Functions

void Activate () override
 
void Deactivate () override
 
NetworkEntityHandle OnPlayerJoin (uint64_t userId, const MultiplayerAgentDatum &agentDatum) override
 
void OnPlayerLeave (ConstNetworkEntityHandle entityHandle, const ReplicationSet &replicationSet, AzNetworking::DisconnectReason reason) override
 

Friends

class SimplePlayerSpawnerTests
 

Detailed Description

A network player spawner. Attach this component to any level's root entity which needs to spawn a network player. If no spawn points are provided the network players will be spawned at the world-space origin.

Member Function Documentation

◆ GetNextSpawnPoint()

AZ::Transform Multiplayer::SimplePlayerSpawnerComponent::GetNextSpawnPoint ( ) const
overridevirtual

Returns the location where the next joining player will be spawned. Method is only valid if called from the multiplayer host/authority; clients are not given information regarding the spawn point index.

Returns
AZ::Transform The location of the next spawn point

Implements Multiplayer::ISimplePlayerSpawner.

◆ GetNextSpawnPointIndex()

uint32_t Multiplayer::SimplePlayerSpawnerComponent::GetNextSpawnPointIndex ( ) const
overridevirtual

Returns the spawn point index where the next joining player will be spawned.

Returns
The index of the next spawn point. Index will be valid except when the spawn point count is zero.

Implements Multiplayer::ISimplePlayerSpawner.

◆ GetSpawnPointCount()

uint32_t Multiplayer::SimplePlayerSpawnerComponent::GetSpawnPointCount ( ) const
overridevirtual

Returns the number of spawn points.

Returns
Number of spawn points.

Implements Multiplayer::ISimplePlayerSpawner.

◆ GetSpawnPoints()

const AZStd::vector< AZ::EntityId > & Multiplayer::SimplePlayerSpawnerComponent::GetSpawnPoints ( ) const
overridevirtual

Returns an immutable list of all the spawn points. Only access this list on the multiplayer host; spawn points are not synced across the network and only the host is responsible for spawning players.

Returns
const AZStd::vector<AZ::EntityId> List of spawn points.

Implements Multiplayer::ISimplePlayerSpawner.

◆ OnPlayerJoin()

NetworkEntityHandle Multiplayer::SimplePlayerSpawnerComponent::OnPlayerJoin ( uint64_t  userId,
const MultiplayerAgentDatum agentDatum 
)
overrideprotectedvirtual

Invoked when a Client connects/ClientHost starts a session to determine what autonomous Prefab should be spawned where

Parameters
userIdUser ID of joining player
agentDatumDatum containing connection data that can be used to inform join logic
Returns
A NetworkEntityHandle of the entity the player will have autonomy over

Implements Multiplayer::IMultiplayerSpawner.

◆ OnPlayerLeave()

void Multiplayer::SimplePlayerSpawnerComponent::OnPlayerLeave ( ConstNetworkEntityHandle  entityHandle,
const ReplicationSet &  replicationSet,
AzNetworking::DisconnectReason  reason 
)
overrideprotectedvirtual

Invoked when a Client disconnects from the session to determine how the autonomous prefab should be cleaned up

Parameters
entityHandleThe entity handle to consider on leaving, generally the connection's primary player entity
replicationSetThe replication set of the related connection
reasonThe cause of disconnection

Implements Multiplayer::IMultiplayerSpawner.

◆ SetNextSpawnPointIndex()

void Multiplayer::SimplePlayerSpawnerComponent::SetNextSpawnPointIndex ( uint32_t  index)
overridevirtual

Overwrites the next joining player's spawn index. The spawn index provided must be a valid (in-bounds) index into the array of available spawn points.

Implements Multiplayer::ISimplePlayerSpawner.


The documentation for this class was generated from the following file: