Constructor
new GameObject(gameEngine, options, id, props)
Creates an instance of a game object.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
gameEngine |
GameEngine | the gameEngine this object will be used in |
||||||
options |
Object | options for instantiation of the GameObject |
||||||
id |
Number | if set, the new instantiated object will be set to this id instead of being generated a new one. Use with caution! |
||||||
props |
Object | additional properties for creation Properties
|
- Source:
Members
(static) bending :Object
Bending is defined as the amount of error correction that will be applied on the client side to a given object's physical attributes, incrementally, by the time the next server broadcast is expected to arrive.
When this percentage is 0.0, the client always ignores the server object's value. When this percentage is 1.0, the server object's attributes will be applied in full.
The GameObject bending attribute is implemented as a getter, and can provide distinct values for position, velocity, angle, and angularVelocity. And in each case, you can also provide overrides for local objects, these attributes will be called, respectively, positionLocal, velocityLocal, angleLocal, angularVelocityLocal.
- Source:
Example
get bending() {
return {
position: { percent: 1.0, min: 0.0 },
velocity: { percent: 0.0, min: 0.0 },
angularVelocity: { percent: 0.0 },
angleLocal: { percent: 1.0 }
}
};
gameEngine :GameEngine
The gameEngine this object will be used in
- Source:
id :Number
ID of this object's instance. There are three cases of instance creation which can occur:
- In the normal case, the constructor is asked to assign an ID which is unique across the entire game world, including the server and all the clients.
- In extrapolation mode, the client may have an object instance which does not yet exist on the server, these objects are known as shadow objects. Their IDs must be allocated from a different range.
- Also, temporary objects are created on the client side each time a sync is received. These are used for interpolation purposes and as bending targets of position, velocity, angular velocity, and orientation. In this case the id will be set to null.
- Source:
playerId :Number
playerId of player who created this object
- Source:
Methods
bendingToString() → {String}
Formatted textual description of the game object's current bending properties.
- Source:
Returns:
description - a string description
- Type
- String
hasComponent(componentClass) → {Boolean}
Check whether this game object has a certain component
Parameters:
Name | Type | Description |
---|---|---|
componentClass |
Object | the comp |
- Source:
Returns:
true if the gameObject contains this component
- Type
- Boolean
onAddToWorld(gameEngine)
Called after the object is added to to the game world. This is the right place to add renderer sub-objects, physics sub-objects and any other resources that should be created
Parameters:
Name | Type | Description |
---|---|---|
gameEngine |
GameEngine | the game engine |
- Source:
onRemoveFromWorld(gameEngine)
Called after the object is removed from game-world. This is where renderer sub-objects and any other resources should be freed
Parameters:
Name | Type | Description |
---|---|---|
gameEngine |
GameEngine | the game engine |
- Source:
syncTo(other)
synchronize this object to the state of an other object, by copying all the netscheme variables. This is used by the synchronizer to create temporary objects, and must be implemented by all sub-classes as well.
Parameters:
Name | Type | Description |
---|---|---|
other |
GameObject | the other object to synchronize to |
- Source:
toString() → {String}
Formatted textual description of the game object.
- Source:
Returns:
description - a string description
- Type
- String