HAPTIC FISHING / STUDY / LEVEL 3 OF 7

Casting: from hand
speed to a parabola.

In the headset you just throw your hand forward. The game has to answer three questions: was that a cast? Where does the bobber go, and how fast? Where does it land, and is that inside the pond? The answers are all in one short file, castPhysics.js. The game and this page use the same copy.

① Hand velocityhow far it moved this frame ÷ how long the frame took
→
② Is it a cast?speed toward the pond > 1.3 m/s
→
③ Launch velocitythe hand's direction, rising at 34°
→
④ Gravity every framea parabola appears; then the landing check

Top view: the mouse is your hand

press the green dot, flick it up toward the pond, release

To make it workable on a screen, 4 cm of mouse movement counts as 1 cm of hand movement. The bobber leaves from the rod tip, about 1.3 m in front of and above the hand.

Numbers right now

ready to cast
Speed toward the pond: 0.00 m/s (the dark line is 1.3; above it counts as a cast)
hand speed |v|
0.00
idle for (idleFor)
0.0 s
launch speed
–
time in the air
–
landing distance from centre
–
result
–
No cast yet.

The side view adds a dashed arc: the same launch speed at the angle you choose, flown with the same flightStep. The game always uses 34° (CAST_ANGLE = 0.6 radians).

Side view: height and distance

each dot is the bobber's position in one frame (1/72 s)

The code in use

castPhysics.js

The file is only a few small functions. As you drag, cast, fly and land, the highlight jumps to the one in use.


      
Full file: castPhysics.js ↗ · where the scene calls it: fishing.js ↗ (search for throwCast and flightStep)

Three things you should be able to explain

  1. Velocity = distance ÷ time. The game does not know you "threw". It only knows where the hand is each frame. Subtract the last position and divide by dt: that is the velocity. To ignore hand jitter, the new value counts for only 40% (cg.mix(old, new, .4)), a simple form of smoothing.
  2. Only the part toward the pond counts. forwardSpeed uses the dot product (dot) to project the velocity onto the direction of the pond. Pulling back or swinging sideways does not count; only throwing toward the pond does.
  3. The parabola is not drawn. Each frame the bobber does two things: its vertical velocity loses 9.8 × dt (gravity), and its position moves by velocity × dt. Repeat that frame after frame and a parabola appears. This is the same "rate × dt" idea as Level 2, called numerical integration.

Exercises: ① Drag the dot up slowly. The speed toward the pond never crosses the line, so nothing is cast. ② Flick hard toward the upper left. Where does the bobber go, and does it land in the pond? ③ After a cast, set the comparison angle to 20°, 34° and 45° and compare where the dashed arc lands. You may have learned that "45° throws farthest". Why is 45° not the farthest here? Hint: the bobber leaves a rod tip 1.9 m high and lands on much lower water.