Class: PlayerSpawnEntity

Class contents

Methods list

These are special functions (or methods) that you may call on the object. these functions typically instruct the object to perform a certain operation.

Public properties list

Properties are attributes of the object, this directly affect the object in question. Some of them can be read or written, or both.
Name Type Description
name string The name of the object
x float The X value of the object's 3D world position
y float The Y value of the object's 3D world position
z float The Z value of the object's 3D world position

Events list

Events are functions you add to your objects, that will be called by Cubiverse when certain things (events) occur.

Class Information

Constructor

new PlayerSpawnEntity()

Creates an instance of a PlayerSpawnEntity, which is passed to the registerPlayerSpawnEntity API call to register it with Cubiverse.

This should normally be created inside a "Player Spawn" Entity cube, which is added to the world using the World Editor.

If you decide to create a PlayerSpawnEntity outside the normal "Player Spawn" Entity cube then Cubiverse cannot guarantee that the spawn point is available when the world is instigated. During world instigation only "Player Spawn" Entity cubes are guaranteed to be created BEFORE any players join the server. Therefore if you use any other cube (or way) to create this entity there is a chance the entity will not be created until a later time (resulting in the entity not spawning players until it's creation).

This:

Properties:

Name Type Description
name string The name of the object
x float The X value of the object's 3D world position
y float The Y value of the object's 3D world position
z float The Z value of the object's 3D world position

Methods

spawnPlayer()

Spawns a player into the world

This method is used to spawn a player ONLY WHEN a new player joins the world. If you perform this API call at any other time then nothing will happen (or you world may be killed in later revisions).

Normally you will call this funtion from the onPlayerSpawn event

This:

Events

onPlayerSpawn

Called when a player needs spawned in the world.

This event can be triggered through a number of different methods. Normally this is a player joining the world and requiring an initial spawn location, but it can also be due to the death of a player or through a reset of the world (such as when a team wins the round).

Normally you will want to call the spawnPlayer API call to have the player spawned.

Parameters:
Name Type Description
PlayerSpawned boolean Indicates whether the player has already been spawned, calling spawnPlayer when this flag is true will result in no operation.
Example
<b>Normal usage for single spawn point</b><br>
function PlayerSpawnObject.onPlayerSpawn( playerSpawned )
{
  if (!playerSpawned)
     this.spawnPlayer() ;
}