# Shake Camera Component

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.

```python
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) 
```

<figure><img src="https://1059887051-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWThJkY8CZ3qBkgyzYFBw%2Fuploads%2FgnlcpP1P6CkvCT1CC51D%2Fcamera_shake.gif?alt=media&#x26;token=c5a3dfb8-1500-49c4-b863-825d5dc78b4b" alt="" width="375"><figcaption><p>Camera shake with strength 15 and fade 5</p></figcaption></figure>
