Extends
Members
# count :number
The number of players in the session.
Type:
- number
Methods
# createPlayer(options) → {Actor}
Spawns a player actor. Called automatically when a new player joins. You should override this method so that it returns your player avatar. Pass the options object to the create method of your avatar class. You can add other custom options to the options object before passing it. (For example, if you wanted to randomly pick a spawn point for the avatar.)
Note: Your player avatar should be extended with the AM_Player mixin.
Name | Type | Description |
---|---|---|
options |
Object | An options object that should be passed to the actor when its created. |
- Type
- Actor
class MyPlayerManager extends PlayerManager {
createPlayer(options) {
options.translation = [0,0,0]; // The default spawn point
return MyPlayerAvatar.create(options);
}
}
class MyPlayerAvatar extends mix(Actor).with(AM_Player) {}
# player(playerId) → {Actor}
Given a playerId, returns a pointer to the avatar associated with the player.
Name | Type | Description |
---|---|---|
playerId |
string | A unique identifier assigned when the player joins. |
- Type
- Actor
# init(name, optionsopt)
Called when the new service is instantiated. An options object may be supplied by the model root. You should overload this when you create your own service and name the service using super.init(). If the service needs to regularly update itself, start a tick here using this.future().
Warning: Never create a service directly. Always use modelServices() in the model root.
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | The public name of the service. Use super.init() in your service to set its name. |
|
options |
Object |
<optional> |
An options object that is supplied to when the service is added. |
- Inherited From:
class MyModelService extends ModelService {
init(options = {}) {
super.init("MyModelServiceName");
// Apply options and perform other initialization.
}
}
# service(name) → {ModelService}
Returns a pointer to the named model service.
Name | Type | Description |
---|---|---|
name |
string | The public name of the model service. |
- Inherited From:
- Type
- ModelService