-
Notifications
You must be signed in to change notification settings - Fork 11
ShakerComponent
Enes Kaplan edited this page Jul 9, 2024
·
1 revision
ShakerComponent is a versatile class that extends Node to provide customizable shaking functionality in Godot 4. It can be used to add shake effects to any property of any node in the scene.
| Property | Type | Description |
|---|---|---|
| custom_target | bool | Flag to use custom targets instead of parent node |
| Targets | Array[Node] | Array of target Node objects to apply shake effect |
| randomize | bool | Flag to enable randomization of shake effect |
| AutoPlay | bool | Flag to automatically start shake effect on ready |
| play | bool | Control to start or stop the shake effect |
| intensity | float | Intensity of the shake effect (0.0 to 1.0 or greater) |
| duration | float | Duration of the shake effect (0.0 for infinite) |
| shake_speed | float | Speed of the shake effect (0.0 to 1.0 or greater) |
| fade_in | float | Fade-in easing of the shake effect |
| fade_out | float | Fade-out easing of the shake effect |
| shakerProperty | Array[ShakerProperty] | Array of ShakerProperty objects defining the shake behavior |
Starts the shake effect.
func play_shake() -> voidvar shaker = get_node("ShakerComponent")
shaker.play_shake()None
Stops the shake effect with a fade-out.
func stop_shake() -> voidvar shaker = get_node("ShakerComponent")
shaker.stop_shake()None
Immediately stops the shake effect.
func force_stop_shake() -> voidvar shaker = get_node("ShakerComponent")
shaker.force_stop_shake()None
Sets the shake progress.
func set_progress(value: float) -> void| Parameter | Type | Description |
|---|---|---|
| value | float | The progress value to set |
var shaker = get_node("ShakerComponent")
shaker.set_progress(0.5)None
-
timeline_progress(progress: float): Emitted when the shake progress changes -
shake_started: Emitted when the shake effect starts -
shake_finished: Emitted when the shake effect finishes -
shake_fading_out: Emitted when the shake effect starts fading out
To use the ShakerComponent:
- Add the ShakerComponent to your scene.
- Set the target node(s) you want to apply the shake effect to.
- Configure the shake properties (intensity, duration, speed, etc.).
- Add ShakerProperty objects to define which properties of the target node(s) should be affected and how.
- Call
play_shake()to start the effect, or setAutoPlayto true for automatic start.