Coder Social home page Coder Social logo

foxssake / netfox Goto Github PK

View Code? Open in Web Editor NEW
292.0 9.0 13.0 4.58 MB

Addons for building multiplayer games with Godot

Home Page: https://foxssake.github.io/netfox/

License: MIT License

GDScript 96.15% Shell 3.85%
godot godot-engine multiplayer online-game netcode

netfox's Introduction

netfox

A set of addons for responsive online games with the Godot engine.

Features

  • โฒ๏ธ Consistent timing across multiple machines
  • ๐Ÿ–ฅ๏ธ Supports client-server architecture
  • ๐Ÿงˆ Smooth motion with easy-to-use interpolation
  • ๐Ÿ’จ Lag compensation with Client-side Prediction and Server-side Reconciliation
  • ๐Ÿ›œ Bullet-proof connectivity with noray integration

Overview

The package consists of multiple addons, each with different features:

  • netfox
    • The core package, implements timing, rollback and other multiplayer features
    • Start here
  • netfox.noray
    • Implements noray integration to establish connection between players
    • Useful for online games
  • netfox.extras
    • Provides high-level, game-specific, convenience features built on top of netfox, like base classes for input management or weapons
    • Check for reusable components for your game
  • netfox.internals
    • Shared utilities for the other addons
    • Included as dependency, no need to install separately

Install

Releases

Find the latest netfox under Releases

Each release contains the addons, and a build of Forest Brawl for Windows and Linux. Each addon has its dependencies packed with it - e.g. "netfox.extras.vx.y.z.zip" also contains both netfox and netfox.internals.

Note: For releases before v1.1.1, a separate ".with-deps.zip" version contains the addon and its dependencies, while the regular zips contain only the addon itself.

Asset Library

Search for the addon name in Godot's AssetLib or download from the site:

Source

Download the source and copy the addons of your choice to your Godot project.

Enable the addons

After adding netfox to your project, make sure to enable the addons in your project settings. Otherwise, Godot will present you with errors about undeclared identifiers.

Upgrading

If you're upgrading from an older version of netfox, refer to the upgrade guide.

Usage

See the docs.

Prototyping

To try your game online with noray, a free to use instance is hosted at tomfol.io:8890, the same instance used by Forest Brawl.

You can use this noray instance to quickly test your games online, but is not recommended for shipping games. The instance has configured limits, and no uptime guarantees are made.

Examples

Comparison sample

To provide a short intro on how to get started with netfox, and how it fares compared to built-in multiplayer tools, a simple demo was implemented as a single-player game, which was ported to multiplayer using both a naive approach and netfox.

Example game

To provide examples of netfox usage in an actual game, Forest Brawl was created and included specifically for this purpose.

It's a party game where an arbitrary amount of players compete by trying to knock eachother off of the map.

Built with netfox

Logo Name Links

Building something cool with netfox? Whether it's released or in progress, feel free to open a PR!

License

netfox is under the MIT license.

Note that the repository contains assets made by other people as well. For these cases, the relevant licenses can be found in the assets' directories.

Issues

In case of any issues, comments, or questions, please feel free to open an issue!

Contribution

Contributions are welcome! Please feel free to fork the repository and open a PR. Ideally, your PR implements a single thing, optionally refers to an existing issue, and follows the GDScript style guide.

Please note that depending on the feature/fix you implement, the PR may need to undergo changes, or in some cases, get rejected if it doesn't fit netfox's intended feature set or vision.

If you feel like it, grant the netfox author(s) write permission to your fork, so we can update the PR if needed.

If you're not sure if the PR would fit netfox or not, open an issue first, mentioning that you'd be willing to contribute a PR.

Author(s) at the time of writing:

  • @elementbound

netfox's People

Contributors

albertok avatar bryanmylee avatar elementbound avatar jonstvns avatar theyellowarchitect avatar zibetnu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netfox's Issues

Extract PropertyEntry logic

Background

While creating TickInterpolator, the same PropertyEntry logic was needed to specify properties to interpolate, as in RollbackSynchronizer. Since that was not exposed, the fastest solution was to just copy the related code and implement the new component. To improve maintainability, it's time to extract that logic.

Done criteria

  1. PropertyEntry class is extracted
  2. PropertyCache class is implemented
    1. Takes a root node on construction
    2. Caches all property entry strings to parsed ones
  3. RollbackSynchronizer uses the new property entries
  4. TickInterpolator uses the new property entries

Rework rollback tick callbacks

Background

Regardless of type, tick callbacks are usually called _tick, which can make code more confusing, both to write, read, and to auto-register rollback handlers in RollbackSynchronizer.

Done criteria

  1. Rollback tick callback method name is configurable
    1. Defaults to _rollback_tick
  2. Code is updated to use new callback name
  3. Rollback callback receives an is_fresh flag
    1. True when this is the first time the object simulates the given tick
    2. Can be used for spawning effects, playing sound, etc.

Resolve TODOs

Multiple TODO's are left over from the original game POC - create new issues for each of them to be resolved.

Notify host when time sync completes

NetworkTime should emit an event when a client completes the time sync. This could be used e.g. for spawning the client's avatar once it has the time synced, so it won't jump around as it updates its time.

Rework timing

Background

Currently, timing is synced to the server at regular intervals. This gives us a good estimate on the server time, but it does fluctuate both forwards and backwards. When the sync happens, rollback logic hitches, as its data is based on now outdated timing.

Done criteria

  • Introduce local_tick and remote_tick on NetworkTime
    • remote_tick is a regularly updated estimate of the server's time
    • local_tick is synced once, at join
  • tick is same as local_tick
  • Rollback logic is based on local tick

Questions

Can we get away with adjusting the local_tick if it's too far away from the estimated remote_tick?

Custom property interpolators

Background

Netfox offers interpolation for various properties. Currently, a bunch of builtin types are supported with a fallback "const" interpolator. However, we'd like to support arbitrary data types, even ones that are specific to the host application. For this, an interpolator registrar mechanism is to be implemented.

Done criteria

  • Introduce Interpolators singleton
  • Interpolators can be registered
    • Interpolators have two methods, is_applicable(v) and interpolate(a, b, f)
  • Interpolators can be queried for a given value
    • The first applicable interpolator is returned
    • If none is applicable, return fallback interpolator
  • RollbackSynchronizer and TickInterpolator uses Interpolators
    • Appropriate interpolator is cached for each property

Fix physics_factor returning wrong value when not in physics frame

Godot has v-sync enabled by default. When turning it off, the fps increases, and movement of networked objects will slow down greatly.

This is due to move_and_slide() taking the current frame delta, instead of always using the physics delta as assumed earlier. This in turn means that NetworkTime.physics_factor is wrong, unless the current fps matches the configured physics tickrate.

Add latency simulation

Background

Testing multiplayer games under different latencies is key to making a good, stable online game. While this is not supported out of the box, it can be done under Linux with the tc command. To make testing easier, it would be nice to have a simple and configurable tool inside Godot to simulate latency.

Done criteria

  1. Implement a MultiplayerPeerExtension to simulate latency
    1. with configurable baseline latency
    2. with configurable jitter
    3. with configurable packet loss chance
    4. wrapped peer can be retrieved
  2. Add project settings for latency simulation
    1. Including all settings for the peer extension
    2. Enable / disable switch
    3. Disable in release switch
  3. Add utility method to wrap peer based on project settings
    1. Creates the peer extension based on project settings
    2. If latency sim is disabled, return a lightweight wrapper that just forwards the calls
    3. Issues warnings based on feature tags on the presence of simulated latency

Provide input age to rewindables

Done criteria

  1. Introduce the concept of input age aware
    1. Aware objects implement the _set_input_age method
    2. NetworkRollback implements utilities ( same as is_rollback_aware and `process_rollback
  2. Simulate nodes regardless of having input
  3. Introduce NetworkRollback.discard(what)
    1. Receives a target object
    2. RollbackSynchronizer doesn't record discarded nodes' states
  4. Update BaseNetInput to be input age aware
  5. Update BrawlerController to discard if input age is not 0

Include all eligible nodes in rollback sim

Background

During rollback, RollbackSynchronizer has a list of nodes to simulate. The list consists of all nodes that:

  • Have state or input, or present in the always simulate list
  • Have the necessary method implemented

This can be sometimes unexpectedly conservative, for example when a node implements some effect but has no state of its own. To make things easier, simply include all child nodes that implement the necessary method.

Done criteria

  1. RollbackSynchronizer resimulates all of the root's child nodes with the _rollback_tick method implemented
  2. Does not list itself

Automate release

Done criteria

  1. A workflow is created to automate releases
  2. Workflow is manually triggered
  3. Zips addons
    1. Zip paths are relative to root, so they can be extracted as-is to any project
    2. Create -with-deps addons that include dependencies
  4. Builds forest-brawlers
  5. Creates tag for version
  6. Attaches addons and builds to release
  7. Generates changelog

Notes

  • Version can be extracted with grep "version=" addons/netfox/plugin.cfg | cut -d"\"" -f2
  • Directories can be zipped with zip -r target.zip /path/to/dir
  • Project can be built with godot --headless --export-release <preset> <path>
  • GH action for releases: https://github.com/softprops/action-gh-release

Fix bomb collisions

Bombs collide with weird and unexpected geometry.

Based on this line, Shapecast's target_position is relative to the node's transform, as a child node would be.

Remove interpolation logic from RollbackSynchronizer

Background

Originally, the state interpolation logic was added to RollbackSynchronizer. However, a bit later, the interpolation logic by itself was needed by things that were synchronized over the network, but without rollback, so TickInterpolator was born. Ideally, RollbackSynchronizer should manage only the rollback logic, and TickInterpolator would handle the tweening.

Done criteria

  1. Move TickInterpolator to netfox
  2. Add enable_recording property to TickInterpolator
    1. When enabled, automatically update from and to state before and after the tick loop
    2. When disabled, do nothing
  3. Add push_state() method to TickInterpolator
    1. Pushes the current state as the next target
  4. Remove interpolation logic from RollbackSynchronizer
  5. RollbackSynchronizer detects sibling TickInterpolator
    1. If present, disable recording and push states manually
    2. This behaviour can be toggled with a property, in case users want to manage interpolation manually

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.