HAPTIC FISHING / STUDY / LEVEL 2 OF 7
The math of
reeling in.
Once a fish is hooked, it is a tug of war. The rules describe it with just two numbers: tension (how tight the line is; 1 is dangerous) and progress (how close the fish is; 1 means landed). Every frame, each number changes at a rate that depends on only two things: are you holding reel, and is the fish surging.
Tension and progress over time
0.0 sThe fight
not startedThe code running right now
fishingRules.jsThe whole fight branch runs every frame. The shaded block is the branch; the highlighted lines are the part this frame actually takes: the if (reel) lines while you hold, the else lines when you let go.
Do the math: can this fish be landed in one pull?
GOLDEN KOIA rate is "change per second". Multiplied by dt, it becomes the change in this frame (the same idea as the countdown timers in Level 1). Rates let you predict what will happen before you try:
Three things you should be able to explain
- Rate × dt.
this.tension += rate * dtis the most common line in game code. Because the rate is written "per second", the result after one second is the same whether the headset runs at 72 or 90 frames per second. - Why "reel, release, reel" wins. While reeling, tension keeps rising and reaches full in about a second. When released, tension falls by 0.9 per second, faster than it rose, while progress slips only a little. A short release is like taking a breath in a tug of war.
- clamp and over.
clampkeeps tension between 0 and 1.15.overcounts how long tension has stayed at full, and resets to 0 as soon as tension drops below 1. So only tension held at full continuously snaps the line.
Exercises: ① Tick "turn off surges", choose the golden koi, and hold reel without letting go. How many seconds until it snaps? Compare with the prediction in the table. ② Untick it and find a rhythm that lands the koi: let go whenever the orange surge band appears. ③ With surges off, set pull to 0 and work it out first: can you land the fish by holding non-stop before the line snaps? Hint: progress must go from 0.25 to 1; tension must go from 0.35 to 1 and then stay there 0.35 s. Compare the two times.