mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-23 12:40:55 +08:00
Updated GarageServer.IO API calls to support client side prediction for entities - #20
This commit is contained in:
@@ -113,7 +113,7 @@ The current ping in milliseconds.
|
||||
|
||||
---
|
||||
```js
|
||||
options.onUpdateClientPredictionReady(callback(playerId, playerCurrentState, inputs, deltaTime))
|
||||
options.onUpdateClientPredictionReady(callback(playerId, playerCurrentState, entityCurrentStates: [, {id, state}], inputs, deltaTime))
|
||||
```
|
||||
If using client side prediction, this callback will fire when you should update player and entity states, based on the current states for player and entities, inputs to be processed, and the delta time.
|
||||
|
||||
@@ -126,6 +126,9 @@ The id of the player.
|
||||
`playerCurrentState` **object literal**
|
||||
The current state of the player.
|
||||
|
||||
`entityCurrentStates` **array**
|
||||
The list of all entities and their current state that were invoked by the player.
|
||||
|
||||
`inputs` **array**
|
||||
List of all the inputs to be processed.
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ GarageServerIO.initializeGarageServer('http://insertmygameserverurlhere.com', {
|
||||
onReady: function () {
|
||||
// Call your game loop
|
||||
},
|
||||
onUpdateClientPredictionReady: function (playerId, playerCurrentState, inputs, deltaTime) {
|
||||
onUpdateClientPredictionReady: function (playerId, playerCurrentState, entityCurrentStates, inputs, deltaTime) {
|
||||
var newState = {};
|
||||
if (!playerCurrentState.x) {
|
||||
playerCurrentState.x = 0;
|
||||
|
||||
@@ -202,13 +202,15 @@ New state of the entity containing all of the properties specific to an entity f
|
||||
#### addEntity
|
||||
---
|
||||
```js
|
||||
GarageServerIO.addEntity(id)
|
||||
GarageServerIO.addEntity(id, referrerId)
|
||||
```
|
||||
|
||||
Notify GarageServer.IO that a new entity has been added to the game.
|
||||
|
||||
`id` **string**
|
||||
Id of the entity to be added.
|
||||
`referrerId` **string**
|
||||
Id of the player who invoked/create the entity - optional and used primarily for client side prediction.
|
||||
#### removeEntity
|
||||
---
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user