Networked Variables
Auto-synced variables.
Introduction
Auto-synced variables. This page provides a complete guide to networked variables in Appley, covering everything from setup to advanced techniques.
Networking is a core area of Appley. Understanding networked variables will help you build better games and use the platform more effectively. This documentation is designed for advanced level users.
Requirements
Before working with networked variables, ensure you have the following:
- A Studio plan subscription (required for multiplayer)
- Understanding of client-server architecture
- An Appley project with multiplayer scenes
- Knowledge of sync and RPC concepts
Estimated Completion Time
Step-by-Step Guide
Follow these steps to work with networked variables in your Appley project:
Enable multiplayer
In project settings, enable multiplayer networking for networked variables.
Set up the lobby
Create a lobby system with room codes and player limits.
Define networked state
Mark variables as networked to auto-sync across clients.
Implement RPCs
Use network.rpc() for remote procedure calls between clients and host.
Test multiplayer
Open the game in two browser tabs to test client-host communication.
FluxScript Example
Below is an Appley Scripting (Flux Scripting) code example demonstrating networked variables:
// Networking — Networked Variables
on start {
if network.isHost {
network.spawn("enemy", vec3(0, 0, 10))
}
}
on playerJoined(player) {
ui.toast(player.name + " joined!")
network.sync("scoreboard", scoreboard)
}
networked score = 0
on update(dt) {
if network.isLocalPlayer {
if input("w") player.move(forward, dt)
if input("f") {
network.rpc("fireWeapon", { pos: player.position })
}
}
}
on rpc("fireWeapon", data) {
effects.spawn("muzzle_flash", data.pos)
audio.play("shoot")
}Node Script Example
The same logic can be implemented using Node Scripting. Here is the equivalent node graph:
[On Start] ──► [Branch: isHost] ──► [Spawn: enemy]
[On Player Joined] ──► [Toast: name + " joined"]
──► [Sync: scoreboard]
[On Update] ──► [Branch: isLocalPlayer]
──► [Input "f"] ──► [RPC: "fireWeapon"]Interchangeable Systems
Common Mistakes
Avoid these frequent mistakes when working with networked variables:
Trusting client-side data
Validate all client input on the host before applying.
Syncing too many variables
Only sync essential state; use RPCs for events.
Not handling player disconnection
Clean up objects and state when a player leaves.
Using large networked payloads
Keep sync data small — send IDs, not full objects.
Troubleshooting
If you encounter issues with networked variables, try these solutions:
Players cannot connect
High latency and lag
State desync between clients
Players see different game states
Performance Tips
Optimize your use of networked variables with these performance tips:
- Use host-authoritative architecture — the host validates all game-critical actions.
- Implement client-side prediction for responsive player movement.
- Use interpolation for remote entities to smooth over network jitter.
- Send only essential data — use IDs and enums, not full strings.
Related Pages
Explore these related documentation pages:
Example Project
Download a complete example project demonstrating networked variables:
