camera-shake

Shake the camera when the player takes damage or on impacts for visual feedback.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "camera-shake" with this command: npx skills add verekia/r3f-gamedev/verekia-r3f-gamedev-camera-shake

Camera Shake

Shake the camera when the player takes damage or on impacts for visual feedback.

Technique

Instantly offset the camera's rotation on X (pitch) and Z (roll) axes, then smoothly return to the base rotation using exponential decay in useFrame.

Key Concepts

  • Store rotation offsets in a module-level object for external triggering
  • Use exponential smoothing: (target - current) * (1 - Math.exp(-speed * dt))
  • Apply offsets to camera.rotation.x and camera.rotation.z
  • Call shake(intensity) from anywhere to trigger the effect

Usage

const shake = (intensity = 0.05) => {
  rotationOffset.x = (Math.random() - 0.5) * intensity
  rotationOffset.z = (Math.random() - 0.5) * intensity
}

// In useFrame:
rotationOffset.x += addSmoothExp(rotationOffset.x, 0, 10, delta)
camera.rotation.x = rotationOffset.x

Related Skills

  • smooth-interpolation - Exponential smoothing formula details

This skill is part of verekia's r3f-gamedev.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

smooth-interpolation

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

reactive-polling

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

ui-useframe

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

bone-attachment

No summary provided by upstream source.

Repository SourceNeeds Review