Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@geckos.io/snapshot-interpolation
Advanced tools
A Snapshot Interpolation library for Real-Time Multiplayer Games
The Interpolation Buffer is by default "latency + 3 serverFrames" long (Interpolation between 4 Snapshots). So if the latency is 30ms and the ServerFrame is 16ms, the Interpolation Buffer would be 78ms long.
If you are interested to learn a bit about Snapshot Interpolation, watch this video.
The github repository contains a nice example. Take a look!
I will create a video in the future that examples the example
# clone the repo
$ git clone https://github.com/geckosio/snapshot-interpolation.git
# cd into it
$ cd snapshot-interpolation
# install all dependencies
$ npm install
# start the example
$ npm start
// import @geckos.io/snapshot-interpolation
import { SnapshotInterpolation } from '@geckos.io/snapshot-interpolation'
// initialize the library (add your server's fps in milliseconds)
const SI = new SnapshotInterpolation(serverFPS)
// your server update loop
update() {
// create a snapshot of the current world
const snapshot = SI.snapshot.create(worldState)
// add the snapshot to the vault in case you want to access it later (optional)
SI.vault.add(snapshot)
// send the snapshot to the client (using geckos.io or any other library)
this.emit('update', snapshot)
}
// import @geckos.io/snapshot-interpolation
import { SnapshotInterpolation } from '@geckos.io/snapshot-interpolation'
// initialize the library
const SI = new SnapshotInterpolation()
// when receiving the snapshot on the client
this.on('update', (snapshot) => {
// read the snapshot
SI.snapshot.add(snapshot)
}
// your client update loop
update() {
// calculate the interpolation for the parameters x and y and return the snapshot
const snapshot = SI.calcInterpolation('x y')
// access your state in snapshot.state.
const { state } = snapshot
// apply the interpolated values to you game objects
const { id, x, y } = state[0]
if (hero.id === id) {
hero.x = x
hero.y = y
}
}
The World State has to be an Array with non nested Objects.
const worldState = [
{ id: 'heroBlue', x: 23, y: 14, z: 47 },
{ id: 'heroRed', x: 23, y: 14, z: 47 },
{ id: 'heroGreen', x: 23, y: 14, z: 47 },
]
The Vault holds and secures all your Snapshots. Each SnapshotInterpolation instance holds one Vault, but you can easily create more if you need:
import { Vault } from '@geckos.io/snapshot-interpolation'
const customVault = new Vault()
You can compress the snapshots manually before sending them to the client, and decompress them when the client receives them. No, compression library is included. You have the freedom to do it however it suits your game best.
FAQs
A Snapshot Interpolation library for Real-Time Multiplayer Games
The npm package @geckos.io/snapshot-interpolation receives a total of 52 weekly downloads. As such, @geckos.io/snapshot-interpolation popularity was classified as not popular.
We found that @geckos.io/snapshot-interpolation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.