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.
|
static void | Reflect (AZ::ReflectContext *context) |
|
static void | GetProvidedServices (AZ::ComponentDescriptor::DependencyArrayType &provided) |
|
static void | GetIncompatibleServices (AZ::ComponentDescriptor::DependencyArrayType &incompatible) |
|
|
class | SimplePlayerSpawnerTests |
|
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.
◆ 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 |
◆ 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()
Invoked when a Client connects/ClientHost starts a session to determine what autonomous Prefab should be spawned where
- Parameters
-
userId | User ID of joining player |
agentDatum | Datum 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
-
entityHandle | The entity handle to consider on leaving, generally the connection's primary player entity |
replicationSet | The replication set of the related connection |
reason | The 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:
- Gems/Multiplayer/Code/Include/Multiplayer/Components/SimplePlayerSpawnerComponent.h