Nearby Connections Transport
A custom Netcode for GameObjects transport enabling peer-to-peer networking over Bluetooth, Wi-Fi Direct, and nearby Wi-Fi using Google Nearby Connections. Designed for local and offline multiplayer scenarios with event-driven architecture and automatic Android permission handling. Supports P2P Star, Cluster, and Point-to-Point topologies.
com.bernatrosello.nearby-connections-transport 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/nearby-connections-transport.git README Markdown
Copy this to your project's README.md
## Installation
Add **Nearby Connections Transport** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/nearby-connections-transport.git
```
[](https://www.pkglnk.dev/pkg/nearby-connections-transport)Dependencies (2)
README
Unity Nearby Connections Transport — Documentation
This folder contains the official documentation for Unity Nearby Connections Transport, a custom transport for Netcode for GameObjects (NGO) built on top of Google Nearby Connections.
These documents describe installation, usage, design intent, platform notes, and known limitations.
Installation
OpenUPM (recommended)
openupm add com.bernatrosello.nearby-connections-transport
When installed through OpenUPM, all required dependencies are resolved automatically.
Manual / Git installation
If you clone or embed this repository manually, you must also install EDM4U.
Required dependency: EDM4U
External Dependency Manager for Unity (EDM4U) is required to resolve and fetch:
- Google Play Services
- The Nearby Connections API used internally by this transport on Android
EDM4U is responsible for generating the correct Gradle dependencies so the Nearby Connections API is included at build time.
Install EDM4U via OpenUPM:
openupm add com.google.external-dependency-manager
Or from GitHub: https://github.com/googlesamples/unity-jar-resolver
Without EDM4U, Android builds will fail or the Nearby API will be missing at runtime.
Quick Start
- Install Netcode for GameObjects
- Install Unity Nearby Connections Transport
- Add
NBCTransportto your scene - Assign it as the Transport in
NetworkManager - Configure Host / Client options
using Netcode.Transports.NearbyConnections;
Connection Model
This transport uses Google Nearby Connections to establish peer-to-peer links over:
- Bluetooth
- Wi‑Fi Direct
- Nearby Wi‑Fi
It is designed for local / offline networking scenarios.
Strategies
- P2P Star — One host, many clients (recommended for NGO)
- P2P Cluster — Mesh-like topology
- P2P Point-to-Point — Single high-bandwidth link
Event-driven design
This transport is purely event-driven:
- No socket polling loop
PollEvent()always returnsNothing- Native callbacks are marshalled onto Unity’s main thread
NGO still receives standard Connect, Disconnect, and Data events.
Android Notes
Permissions
The following permissions are required and requested at runtime:
- Bluetooth Scan / Connect / Advertise
- Nearby Wi‑Fi Devices
- Location (required by Nearby Connections)
Permission handling is automatic on Android builds.
Build system
- Java bridge compiled as an Android library
- Native C++ plugin accessed via P/Invoke
- Google Play Services resolved through EDM4U
Performance Notes (Initial Release)
This is the first public release of the transport.
Observed performance
Initial testing shows:
- ~160 ms mean ping in typical local scenarios
- Performance varies based on:
- Connection strategy
- Radio technology selected by Nearby
- Device hardware
These values are expected for Nearby Connections, which prioritizes reliability and discovery over raw latency.
Profiling tools
You can profile runtime behaviour using:
For deeper analysis of the underlying Nearby Connections API, a dedicated performance report was conducted using a custom release of:
https://github.com/BernatRosello/AtomD/
This external tool focuses on evaluating Nearby Connections behaviour independent of NGO.
More performance tuning and benchmarks are planned for future releases.
Limitations
Android is the primary supported platform
iOS / visionOS bindings are stubs, which contributors might want to submit PRs for, a good starting point might be found in the work being done over at the google/nearby/connections repo. Though this isn't the actual implementation of Nearby Connections that runs natively on Android (closed source), it does presumptuously share interfaces with it. In fact a fork of this repo was used to develop the C++ JNI bindings that call into the underlying java code used on this package, those might be of help too.
Throughput and latency are constrained by Nearby Connections
Not intended for large-scale or internet-based multiplayer
Intended Use Cases
- Local multiplayer games
- Party / couch co‑op
- Device‑to‑device discovery
- Offline networking scenarios
License
MIT License
Status
This transport is under active development.
Feedback, issues, and contributions are welcome.
No comments yet. Be the first!