Skip to content

Call With Code

Enes Kaplan edited this page Jul 9, 2024 · 1 revision

Shaker

The Shaker class extends Node and provides methods for applying various shake effects to nodes in a 2D or 3D environment.

Class Definition

extends Node

shake_by_preset

Applies a shake effect to a node using a specified preset.

Syntax

Parameter Type Description
preset ShakerPresetBase The shake preset to apply
node Node The target node to shake
duration float Duration of the shake effect
speed float Speed of the shake (default: 1.0)
intensity float Intensity of the shake (default: 1.0)
fade_in float Fade-in duration (default: 0.25)
fade_out float Fade-out duration (default: 2.0)

Example

var _preset:ShakerPreset3D = load("res://addons/shaker/data/resources/strong_shake.tres")
Shaker.shake_by_preset(_preset, self, 1.0, 1.0)

Return Value

This method does not return a value.

shake_property

Applies a shake effect to a specific property of a node.

Syntax

Parameter Type Description
property ShakerProperty The property to shake
node Node The target node
duration float Duration of the shake effect
speed float Speed of the shake (default: 1.0)
intensity float Intensity of the shake (default: 1.0)
fade_in float Fade-in duration (default: 0.25)
fade_out float Fade-out duration (default: 2.0)

Example

Shaker.shake_property(ShakerProperty.new("offset_y", ShakerTypeSineWave1D.new()), self, 1.0, 1.0)

Return Value

Returns a ShakerComponent instance.

shake_emit_3d

Creates a 3D shake emitter at a specified position.

Syntax

Parameter Type Description
position Vector3 The global position of the emitter
preset ShakerPreset3D The shake preset to use
max_distance float Maximum distance of effect
duration float Duration of the shake effect
distance_attenuation float Attenuation over distance (default: 0.5)
speed float Speed of the shake (default: 1.0)
fade_in float Fade-in duration (default: 0.25)
fade_out float Fade-out duration (default: 2.0)

Example

var _preset:ShakerPreset3D = load("res://addons/shaker/data/resources/strong_shake.tres")
Shaker.shake_emit_3d(explosion.global_position, _preset, 6, 1.0)

Return Value

Returns a ShakerEmitter3D instance.

shake_emit_2d

Creates a 2D shake emitter at a specified position.

Syntax

Parameter Type Description
position Vector2 The global position of the emitter
preset ShakerPreset2D The shake preset to use
max_distance float Maximum distance of effect
duration float Duration of the shake effect
distance_attenuation float Attenuation over distance (default: 0.5)
speed float Speed of the shake (default: 1.0)
fade_in float Fade-in duration (default: 0.25)
fade_out float Fade-out duration (default: 2.0)

Example

# Load or create a ShakerPreset2D
var preset_2d:ShakerPreset2D = load("res://path/to/your/2d_preset.tres")
Shaker.shake_emit_2d(explosion2d.global_position, preset_2d, 128, 1.0)

Return Value

Returns a ShakerEmitter2D instance.

Clone this wiki locally