Skip to content

feat: scream when hedgehog is harshly thrown#2438

Closed
fercgomes wants to merge 1 commit into
mainfrom
posthog-code/wilhelm-scream-on-hedgehog-throw
Closed

feat: scream when hedgehog is harshly thrown#2438
fercgomes wants to merge 1 commit into
mainfrom
posthog-code/wilhelm-scream-on-hedgehog-throw

Conversation

@fercgomes
Copy link
Copy Markdown
Contributor

Summary

When hedgehog mode is enabled and the user grabs the hog and flings it sharply upward, play the Wilhelm scream.

  • Detection is purely renderer-side via the @posthog/hedgehog-mode package's public API: on every pointerup we defer one animation frame so Matter.js has applied the post-release velocity, then inspect each hedgehog's rigidBody.velocity. If a hog is moving upward faster than the autonomous jump speed (y < -25 AND speed > 25), we play the scream at the user's completionVolume.
  • The wilhelm.mp3 asset already shipped as a selectable task-completion sound; this just wires it to throw releases as well via a new one-shot playSoundUrl helper that doesn't interfere with the completion-sound audio chain.

Thresholds are an initial guess (25 in Matter.js units, comfortably above the autonomous jump() velocity of 15). Easy to tune.

Test plan

  • pnpm --filter code typecheck (already green locally)
  • Enable hedgehog mode in settings
  • Grab the hog and fling it sharply upward → Wilhelm scream plays
  • Grab the hog and drop/shake it sideways at moderate speed → no scream
  • Let the hog jump autonomously → no scream
  • Trigger a task-completion sound, then immediately throw the hog → both audio clips play (do not cancel each other)
  • Set completionVolume = 0 → throws are silent
  • Disable hedgehog mode → no scream on subsequent pointerups

When hedgehog mode is enabled and the user grabs the hog and flings it sharply upward, play the Wilhelm scream.

Detection is purely renderer-side via the hedgehog-mode package's public API: on every pointerup we defer one animation frame so Matter.js has applied the post-release velocity, then inspect each hedgehog's rigidBody.velocity. If a hog is moving up faster than the autonomous jump speed (y < -25, speed > 25), we play the scream at the user's completionVolume.

The wilhelm.mp3 asset already shipped as a selectable task-completion sound; this just wires it to throw releases as well via a new one-shot playSoundUrl helper that doesn't interfere with the completion-sound audio chain.

Generated-By: PostHog Code
Task-Id: a92f24e3-30a1-4e8d-a6e8-5fb508ef9993
@fercgomes fercgomes closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant