Tanks Multiplayer  1.4
Public Member Functions | Public Attributes | List of all members
ObjectSpawner

Manages network-synced spawning of prefabs, in this case collectibles and powerups. With the respawn time synced on all clients it supports host migration too. More...

Inheritance diagram for ObjectSpawner:

Public Member Functions

override void OnStartServer ()
 Server only: check if the object is active in the scene already, then the host or migrated host does not have to do anything. If the object is not active, the host has to continue with the SpawnCoroutine where it left off More...
 
void Instantiate ()
 Server only: spawns the prefab over the network, making use of object pooling. Keeps the parent-child tracking by setting the network id to this managing gameobject. More...
 
void Pickup (NetworkInstanceId viewId)
 Collects the object and assigns it to the player with the corresponding view. More...
 
void Drop (Vector3 position)
 Unparents the object from any carrier and drops it at the targeted position. More...
 
void Return ()
 Returns the object back to this spawner's position. E.g. in Capture The Flag mode this can occur if a team collects its own flag, or a flag timed out after being dropped. More...
 
void Destroy ()
 Server only: Called by the spawned object to destroy itself on this managing component. This could be the case when it has been collected by players. More...
 
void SetRespawn ()
 Sets the next spawn time in 'respawnTime' seconds from now on, measured in game time. This is done on all clients too, so that everyone can continue where the old host has left off to not disrupt the timed spawn intervals of collectibles. More...
 

Public Attributes

GameObject prefab
 Prefab to sync the instantiation for over the network. More...
 
bool respawn
 Checkbox whether the object should be respawned after being despawned. More...
 
int respawnTime
 Delay until respawning the object again after it got despawned. More...
 
GameObject obj
 Reference to the spawned prefab gameobject instance in the scene. More...
 
CollectionType colType = CollectionType.Use
 Type of Collectible this spawner should utilize. This is set automatically, thus hidden in the inspector. Fires network messages depending on type. More...
 

Detailed Description

Manages network-synced spawning of prefabs, in this case collectibles and powerups. With the respawn time synced on all clients it supports host migration too.

Member Function Documentation

void Destroy ( )

Server only: Called by the spawned object to destroy itself on this managing component. This could be the case when it has been collected by players.

void Drop ( Vector3  position)

Unparents the object from any carrier and drops it at the targeted position.

void Instantiate ( )

Server only: spawns the prefab over the network, making use of object pooling. Keeps the parent-child tracking by setting the network id to this managing gameobject.

override void OnStartServer ( )

Server only: check if the object is active in the scene already, then the host or migrated host does not have to do anything. If the object is not active, the host has to continue with the SpawnCoroutine where it left off

void Pickup ( NetworkInstanceId  viewId)

Collects the object and assigns it to the player with the corresponding view.

void Return ( )

Returns the object back to this spawner's position. E.g. in Capture The Flag mode this can occur if a team collects its own flag, or a flag timed out after being dropped.

void SetRespawn ( )

Sets the next spawn time in 'respawnTime' seconds from now on, measured in game time. This is done on all clients too, so that everyone can continue where the old host has left off to not disrupt the timed spawn intervals of collectibles.

Member Data Documentation

Type of Collectible this spawner should utilize. This is set automatically, thus hidden in the inspector. Fires network messages depending on type.

GameObject obj

Reference to the spawned prefab gameobject instance in the scene.

GameObject prefab

Prefab to sync the instantiation for over the network.

bool respawn

Checkbox whether the object should be respawned after being despawned.

int respawnTime

Delay until respawning the object again after it got despawned.


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