Addons documentation
  • 😄Getting Started
  • 🧩Components
    • 👟Godot Essentials Motion Component
      • 🤸Top-Down Movement Component
      • 🤾Platform Movement Component
      • 🔲Grid Movement Component
    • 💓Health Component
    • 🎥Shake Camera Component
    • 🌪️Rotator Component
    • 🚀Projectile component
    • 🔁Finite State Machine
  • ⏳Autoload
    • 🎒Helpers
    • 🎧AudioManager
    • 🎬Scene Transicioner
    • ⚙️Environment variables
    • 🏆Achievements
  • 🎮Examples
    • 🧗‍♂️Alys - Precision platformer
Powered by GitBook
On this page
  • # Setup
  • Example
  1. Components

Shake Camera Component

Apply this recurring effect in video games in an easy way

Add this component as a child of Camera2D and you're ready to go. It's easy as calling the function shake() with the desired parameters. The offset in each frame changes randomly so provide a a better experience in every shake and makes it unique.

# Setup

  • Default shake strength

  • Default fade

The shake strength defines the the amount of vibration in the camera movement, the greater the force, the greater the distance of camera shake.

The fade is the intensity of attenuation at which the shaking effect is decreasing

Example

Create a CharacterBody2D and add a Camera2D to it, then add the ShakeCameraComponent2D as a child of Camera2D.

For demo purposes we trigger the shake with default values pressing a key but this can change depending on how you want to run it in the game.

extends CharacterBody2D

@onready var shake_camera_component_2d = $Camera2D/ShakeCameraComponent2D

func _process(delta):
	if Input.is_action_just_pressed("shake"):
		shake_camera_component_2d.shake()
		# or you can define your own strength and fade parameters
		shake_camera_component_2d.shake(30.0, 10.5) 
PreviousHealth ComponentNextRotator Component

Last updated 1 year ago

🧩
🎥
Camera shake with strength 15 and fade 5