8.7 KiB
Harvest Season — co-op
Two players keep the farm together: each has a scarecrow, and both play the same vacation.
Co-op runs on GD-Sync (addons/GD-Sync/, version 1.0.2), the
multiplayer plugin; its autoload is GDSync.
Playing together
Main menu → Play with a friend. Enter your name (shown over your scarecrow), then pick how to connect:
| Connect | What it needs | How the friend finds you |
|---|---|---|
| Same network (LAN) | Nothing: GD-Sync's local mode is peer to peer, with no account or keys | Join lists the games announced on the network |
| LAN by address | The host's address (shown in the host's status line: "or by address: 192.168.1.20") | Join → type the address → Join. Use it when the list stays empty: some firewalls drop the announcements, and VPNs like Tailscale or ZeroTier don't carry them, but connect fine by address |
| Online | The project's GD-Sync API keys (below) | Join lists the open games, or type the game's name ("Ana's farm") |
- Host a game: pick the vacation (continue your save, or a new one), and the farm opens to your friend. You play right away; your friend can join, leave, and rejoin at any time.
- Join a game: pick it from the list (or type its address or name). You arrive on the host's farm as player 2, mid-day or mid-night, wherever the host is.
Online play: the API keys
Online lobbies go through GD-Sync's servers, which need the project's keys (a free account at gd-sync.com gives them):
- In the Godot editor, open Project → Tools → GD-Sync.
- Paste the public and private keys.
GD-Sync saves them to addons/GD-Sync/keys.cfg. That file is in .gitignore; never commit it.
The keys can also come from the GDSYNC_PUBLIC_KEY and GDSYNC_PRIVATE_KEY environment
variables. Without keys, the menu says so and LAN still works.
Exported builds get the keys automatically: GD-Sync's export plugin writes keys.cfg into
every export. Anyone with a build can read them, which is how GD-Sync works for every game. If
the keys leak somewhere they shouldn't, make new ones at gd-sync.com.
Voice chat
On by default when both are in: your microphone is sent whenever it's above room noise (GD-Sync's
VoiceChat), and your friend's voice plays on the Voice bus.
- [M] mutes and unmutes your microphone; Settings → Co-op does the same.
- Settings → Audio → "Voice chat (your friend)" sets their volume.
- While your friend is talking, a speaker mark shows on their panel.
- Use headphones: an open microphone picks up the game's sound from speakers.
In the game
- Tags and colors. Name tags over both scarecrows: P1 (the host) in gold, P2 in blue. Player 2's scarecrow is tinted blue.
- Partner panel (above your own health):
- their name, health, and what they're doing (down until morning, patching, gathering, fear ready);
- "talking" while their voice comes through, and the ping;
- your microphone's state.
- Edge arrow: when your friend is off screen, an arrow at the edge points to them, with the distance.
- Everything is shared: the shed, the pouch, upgrades, structures, and the vacation itself. Either player can gather, build, repair, buy upgrades, and start the day.
- Health is your own. Upgrades to max health apply to both scarecrows.
- A scarecrow at 0 HP is out until the morning. It lies there and the camera follows the other one. It comes back each morning at half health. Game Over only when both are down at once.
- Enemies go for the nearer scarecrow. Animals follow whoever picked them up.
- The host's game is the real one and it saves (the partner's doesn't). Retry, starting the night early, and the end screens work from either side; only the host can restart the night from the pause menu.
- Menus don't pause co-op. Your scarecrow stands still while your menu is up.
- Leaving:
- If the partner leaves, the host plays on alone.
- If the host leaves, the partner is back at the main menu, which says why.
- A co-op save continued alone plays by the solo rules.
How it works
The host's farm simulates everything: both scarecrows, every enemy, the loot, the animals, and the
campaign. The partner's farm is a replica (FarmSim.replica). It simulates nothing and shows what
the host sends, except the partner's own scarecrow. The partner moves that scarecrow itself, so
moving never waits on the network, and sends its position, facing, and buttons to the host, where
it acts.
| Piece | File | Does |
|---|---|---|
CoopSession |
game/scripts/coop_session.gd |
The protocol, on both sides: the welcome, snapshots (the clock, both scarecrows with the weapon in hand and the bomb's recharge, animals, enemies in 16-byte records, shots) 20 times a second, the farm state and the loot when they change, news in order (phase changes, the end, sounds, toasts, loot news, breaches, fear bursts, attacks, pumpkin bombs thrown, gather popups), and the partner's input (with its pick of weapon) and requests. The partner's own weapons only aim and show their motion: the host attacks for it, so nothing is hit twice |
CoopLink, GDSyncLink |
coop_link.gd, gdsync_link.gd |
The wire: GD-Sync remote calls, reliable or not; a loopback pair for tests |
CoopLobby |
coop_lobby.gd |
GD-Sync's LAN and online modes, lobbies, join by address |
RemoteControls |
remote_controls.gd |
The partner's buttons as the host sees them: held state, press counts (a lost packet never loses a press), aim, build mode, menus |
Avatar |
avatar.gd |
One scarecrow and its kit, weapons, and hands; FarmSim.avatars holds both |
CoopVoice |
coop_voice.gd |
GD-Sync's VoiceChat, one per player, owned by that player |
CoopHud, CoopMenu |
coop_hud.gd, coop_menu.gd |
The partner panel and arrow; the menu |
Messages that may be lost (snapshots, input) stay under 1,100 bytes. GD-Sync splits datagrams at 1,200. Nothing depends on any one of them arriving: an enemy missed by a snapshot appears in the next, and removals are reliable.
Measured on the loopback test with 90 enemies and a third of the snapshots dropped: about 31 KB/s from the host and 10 KB/s from the partner, with the largest message under the limit. That's nothing on a LAN. Online, check it against your GD-Sync plan's data allowance.
Testing
game/tests/test_coop.gd(in the main suite) runs host and partner in one process: the partner's farm sits in its own world, over the loopback link. It covers the join, requests, the partner moving, gathering, and shooting (and its pick of weapon), the host's stabs and pumpkin bombs drawn on the partner's farm (harmless there), enemies, loot, and shots arriving, the fall rule and Retry, a crowd with dropped packets, message sizes, and either side leaving.game/tools/coop_smoke.gdplays a real GD-Sync LAN game between two processes on one machine. The partner joins by address, since broadcasts don't loop back on every machine;--discoveruses the network announcements instead.--onlineplays through GD-Sync's servers (needs the keys): the partner finds the host's lobby in the online list. Give both sides the same--host-name, so an old lobby from an earlier run isn't picked by mistake.
godot --headless --path . --script res://game/tools/coop_smoke.gd -- --role=host &
godot --headless --path . --script res://game/tools/coop_smoke.gd -- --role=join
# online:
godot --headless --path . --script res://game/tools/coop_smoke.gd -- --role=host --online --host-name=Smoke1 &
godot --headless --path . --script res://game/tools/coop_smoke.gd -- --role=join --online --host-name=Smoke1
Online, tested (2026-10-04): both sides passed. The partner found and joined the lobby in about 2 s, and played the day and the night with 24 enemies.
Not tested here: discovery between two machines (this one's firewall drops broadcasts), online play between two machines on different networks, and voice with real microphones (headless has none).
Patches to GD-Sync
Four small patches, each marked Harvest Season patch in the code. Re-apply them after updating
the plugin.
| File | Patch | Why |
|---|---|---|
Scripts/ConnectionController.gd |
LAN client ids fit in 30 bits | Targeted calls carry the id in 30 bits (RequestProcessor.encode_target_client). A random 32-bit LAN id got cut off, and calls to that player reached nobody. |
Scripts/RequestProcessor.gd |
A fixed HMAC key in LAN mode | Without API keys the key is empty, and Godot logs an error for every unreliable packet |
Scripts/SessionController.gd, Scripts/Types/NodeInstantiator.gd |
Null checks for the current scene | Tests and tools run without one (--script) |
Scripts/Logger.gd |
Only talk to the debugger when one is attached | Same |