HAPTIC FISHING / STUDY / LEVEL 7 OF 7

Playing
together.

Two headsets never share "one game". Each device runs its own copy of the game and, 15 times a second, sends the others a tiny snapshot: where my rod is, what state I am in, my score. The others draw me from it. This page simulates two players and a network whose delay and loss you control. Who is at the pond, when the match starts and who won are decided by the game's own pondSync.js.

My gameruns on my headset: bites and vibration stay local
→
Snapshot × 15 per secondrod position, state, score: about 100 bytes
→
The course server relays itthis takes time (latency), and sometimes it is lost
→
Their gamedraws me smoothly, decides who is here and who won

What each headset sees

Player A's headset

orange is A

Player B's headset

blue is B

The network

the course server relays messages to everyone else

Make trouble

and watch what happens

Each device uses its own clock to decide whether the match has started. If a clock is wrong, one player starts early and the other late.

The multiplayer rules

pondSync.js


      

Where the scene uses them

fishing.js

① START: begin a new match or join the one that is running. ② Every frame: who is here, whether to join, whether someone has won. ③ Fifteen times a second: send my snapshot, then draw everyone else smoothly.


      
    

What you should be able to explain

  1. Everyone runs their own game and shares only results. Bites, vibration and tension are computed on your own headset; only a small snapshot of position, state and score is sent. However slow the network, your own feel of the game is unaffected.
  2. Each player writes only their own slot. In the shared state fishingPond, only A writes p0, only B writes p1, and match is written by whoever presses START. Nobody ever changes the same slot at the same time, so nothing is overwritten.
  3. Latency and smoothing. A snapshot takes time to arrive, so what you see of the other player is always "them a moment ago" (compare the dot with the dashed ring). Smoothing (moving a little toward the latest position every frame) makes their motion continuous, at the cost of a little more delay. This is a simple form of interpolation.
  4. Presence from recent messages. If no new snapshot arrives from someone for 2.5 s, they are treated as gone (STALE). This is sometimes called a heartbeat or timeout.
  5. Starting together by agreeing on a time. START broadcasts only a start time, t0; each device checks its own clock. So device clocks need to be accurate (clock synchronization).

Exercises: ① Set latency to 500 ms and see how far B's dot trails the dashed ring in A's view. Then turn smoothing off: what changes? ② Tick "B goes offline" and count how long it takes for B to disappear in A's view; compare with STALE. ③ Let A press START and watch both countdowns. Then set B's clock error to +1.5 s and try again: do they still start together? ④ During a match, let A catch four fish. What does B's headset show, and which function noticed?