Skip to content
PhantomCameraNoiseEmitter2D

PhantomCameraNoiseEmitter2D ​

Inherits: Node2D

Is a node meant to apply positional and rotational noise, also referred to as shake, to the Camera2D. It is designed for use cases such as when hitting or when being hit, earthquakes or to add a bit of slight movement to the camera to make it feel less static.

The emitter can affect multiple PCams in a given scene based on which noise_emitter_layer are enabled.

To trigger the emitter, simply call its emit function.

Properties ​

noise ​

Type: PhantomCameraNoise2D

Default: null

The PhantomCameraNoise2D resource that defines the noise pattern for this emitter.


Setter ​

void set_noise (PhantomCameraNoise2D noise_resource)

Example
gdscript
pcam_emitter.set_noise(noise_resource)

Getter ​

PhantomCameraNoise2D get_noise()

Example
gdscript
pcam_emitter.get_noise()

preview ​

Type: bool

Default: false

If true, previews the noise in the editor - can be seen in the viewfinder.

Note: This property is only accessible within the node's inspector panel in the editor.

continous ​

Type: bool

Default: false

If true, repeats the noise indefinitely once started. Otherwise, it will only be triggered once.


Setter ​

void set_continuous (bool value)

Example
gdscript
pcam_emitter.set_continuous(true)

Getter ​

bool get_continuous()

Example
gdscript
pcam_emitter.get_continuous()

growth_time ​

Type: float

Default: 0

Determines how long the noise should take to reach full intensity once started.

The value is set in seconds.


Setter ​

void set_growth_time (float value)

Example
gdscript
pcam_emitter.set_growth_time(0.1)

Getter ​

float get_growth_time()

Example
gdscript
pcam_emitter.get_growth_time()

duration ​

Type: float

Default: 1

Sets the duration for the camera noise if continuous is set to false.

The value is set in seconds.


Setter ​

void set_duration (float value)

Example
gdscript
pcam.set_duration(0.42)

Getter ​

float get_duration()

Example
gdscript
pcam_emitter.get_duration()

decay_time ​

Type: float

Default: 0

Determines how long the noise should take to come to a full stop.

The value is set in seconds.


Setter ​

void set_decay_time (float value)

Example
gdscript
pcam_emitter.set_decay_time(0.1)

Getter ​

float get_decay_time()

Example
gdscript
pcam_emitter.get_decay_time()

noise_emitter_layer ​

Type: int

Default: 1

Enabled layers will affect PhantomCamera2D nodes with at least one corresponding layer enabled.

Enabling multiple corresponding layers on the same PhantomCamera2D causes no additional effect.

Note: The layer value uses a bitmask.

Tip

A helper function also exists called set_noise_emitter_layer_value(), where you can supply a specific layer number and then enable / disable it (see setter example below). Use this if you prefer not having to supply bitmask values.


Setter ​

void set_noise_emitter_layer (int value)

void set_noise_emitter_layer_value (int layer, bool enabled)

Example
gdscript
# Bitmask assignment
pcam_emitter.set_noise_emitter_layer(8) # Enables the 4th layer using bitmask value

## Specific layer change
pcam_emitter.set_noise_emitter_layer_value(4, true) # Enables the 4th layer

Getter ​

int get_noise_emitter_layer()

Example
gdscript
pcam_emitter.get_noise_emitter_layer() # Returns the layer value as a bitmask

Methods ​

void emit ​

Emits the noise from the emitter based on the applied PhantomCameraNoise2D resource and various properties assigned.
It will affect all active PCam3Ds with at least one matching noise_emitter_layer.

Example
gdscript
noise_emitter.emit()

bool is_emitting ​

Returns the state for the emitter. If true, the emitter is currently emitting.

Example
gdscript
noise_emitter.is_emitting()

void stop ​

Stops the emitter from emitting noise.

Example
gdscript
noise_emitter.stop()

void toggle ​

Toggles the emitter on or off.

Example
gdscript
noise_emitter.toggle()

Made with ♥ in Vitepress