Menu
Lumberyard
User Guide (Version 1.13)

Lightning

This feature is in preview release and is subject to change.

You can use the Lightning component to create a single lightning bolt effect. In Lumberyard Editor, you can add the Lightning component to entities and trigger them later from Lua or Script Canvas. For best results, use the Lightning component as part of a dynamic slice along with a spawning system. After the Lightning component finishes its effect, the entity is automatically destroyed. This makes it easier for you to spawn entities with a Lightning component, without needing manually to manage the lifetime of each entity.

The Lightning component does not produce visual effects on its own. The component schedules timings with a specified set of entities. You can use the following components to create the lightning bolt effect:

  • Particle component emitter to create the lightning bolt.

  • A Light component for the dynamic lighting and shadowing. You can use any of the light components, but the Point Light component is recommended.

  • Sky Highlight component for the bright flash in the sky.

  • Audio Trigger and Audio Proxy components for the rumbling of thunder.

  • The Lightning component to manage the lifetimes and intensities of the other entities to create a flash of lightning.

To enable the Lightning component, you must enable the Lightning Arc gem. For more information, see Lightning Arc Gem.

Example

The Lightning component randomly spawns in a small area.


                Add the Lightning component to your entity to enable
                    lightning effects in your level.

Lightning Component Properties

The Lightning component has the following properties:

Start to Activate

Specifies whether lightning effects start when the Light component activates.

Default value: True

Relative to Player

Specifies whether the lightning effects are relative to the current active camera.

Default value: True

Duration

Amount of time in seconds that the lightning strike lasts.

The particle effect lasts for the specified duration; the lighting effects can flash multiple times depending on how quickly the light intensity disappears.

Default value: 0.2

Valid values: 0 to ∞

Lightning Bolt

The Lightning component has the following lightning bolt options:

Particle Entity

(Optional) An entity with a Particle component that creates a lightning bolt effect. This particle can be emitted multiple times depending on the duration of the effect.

Size Variation

Specifies how much of the particle entity's global size parameter is randomly modified. For more information, see SetParticleSizeVariation.

Default value: 0.2

Valid values: 01

SkyHighlight

The Lightning component has following sky highlight options:

Sky Highlight Entity

(Optional) An entity with a Sky Highlight component that creates a flash of light in the sky. The properties of the Sky Highlight component are respected.

Light

The Lightning component has following light options:

Light Entity

(Optional) An entity with a Light component that creates dynamic lightning. The properties of the Light component are the same, but its intensity and radius are modified.

(Point Light is recommended)

Radius Variation

Specifies how much the light's radius is randomly modified. For more information, see SetLightRadiusVariation.

Default: 0.2

Valid values: 0 to 1

Intensity Variation

Specifies how much the light's intensity is randomly modified. For more information, see SetLightIntensityVariation.

Default: 0.2

Valid values: 0 to 1

Audio

The Lightning component has following audio options:

Audio Entity

An entity with the Audio Trigger and Audio Proxy components attached. These components are required if you want to enable audio. You can also add an optional Audio Rtpc component. The audio components plays the audio, depending on the distance away from the listener.

Speed of Sound Scale

Specifies how long it takes for audio to arrive at the listener, in seconds. For more information, see SetSpeedOfSoundScale.

Default: 1

Valid values: 0 to 100

EBus Request Bus Interface

Use the following request functions with the EBus interface to communicate with other components of your game. You can use this EBus to communicate to an entity with a Lightning component attached. The EBus is available at game run time and editing and can be accessed from C++, Lua, and the Script Canvas editor.

For more information about using the event bus (EBus) interface, see Working with the Event Bus (EBus) System.

StartEffect

Enables the lightning effect.

Parameters

None

Return

None

Scriptable

Yes

SetStartOnActivate

Specify if the lightning effect starts when the Lightning component activates.

Note

This function is useful only during edit time.

Parameters

Type: Boolean

Return

None

Scriptable

Yes

GetStartOnActivate

Returns true if the lightning effect starts when the Lightning component activates.

Parameters

None

Return

Type: Boolean

Scriptable

Yes

SetRelativeToPlayer

Specify if the start of the lightning effect is relative to the player camera.

Parameters

Type: Boolean

Return

None

Scriptable

Yes

GetRelativeToPlayer

Returns true if the start of the lightning effect is relative to the player camera.

Parameters

Type: Boolean

Return

None

Scriptable

Yes

SetLightningParticleEntity

Sets the entity that contains the Particle component that is used for the lightning particle.

The entity is destroyed when the effect finishes.

Parameters

Type: AZ::EntityId

Return

None

Scriptable

Yes

GetLightningParticleEntity

Returns the entity that contains the Particle component.

Parameters

None

Return

Type: AZ::EntityId

Scriptable

Yes

SetLightEntity

Sets the entity that contains the Light component, which is used for lightning effects.

The entity is destroyed when the effect finishes.

Parameters

Type: AZ::EntityId

Return

None

Scriptable

Yes

GetLightEntity

Returns the entity that contains the Light component.

Parameters

None

Return

Type: AZ::EntityId

Scriptable

Yes

SetSkyHighlightEntity

Sets the entity that has the Sky Highlight component for this effect.

The entity is destroyed when the effect finishes.

Parameters

None

Return

Type: AZ::EntityId

Scriptable

Yes

GetSkyHighlightEntity

Returns the entity that has the Sky Highlight component.

Parameters

None

Return

Type: AZ::EntityId

Scriptable

Yes

SetAudioEntity

Sets the entity that has the audio component for this effect.

To enable audio, the entity must have the Audio Trigger and Audio Proxy components and an optional Audio Rtpc component. If an audio component is missing, the lightning effect may not work as expected.

The entity is destroyed when the effect finishes.

Parameters

Type: AZ::EntityId

Return

None

Scriptable

Yes

GetAudioEntity

Returns the entity that has the audio component.

Parameters

None

Return

Type: AZ::EntityId

Scriptable

Yes

SetSpeedOfSoundScale

Sets the speed of sound scale for this effect. You can use this parameter if want the audio to take more or less time to reach the player and you don't want to move your lightning effect.

Note

Sound travels at 340.29 meters per second. A value of 0.5 makes sound from this effect take half as much time to reach the player.

Parameters

Type: Float

Return

None

Scriptable

Yes

GetSpeedOfSoundScale

Returns the speed of sound scale for this effect.

Parameters

None

Return

Type: Float

Scriptable

Yes

SetLightRadiusVariation

Sets the amount of random variation to apply to the light's radius.

This variation is a percentage of the light's radius. A value of 0.2 means that between –20% and 20% of the light's radius value is added back to the light's radius.

For example, the light radius is 5.0, and variation is 0.2; this means that the range of the light radius is: 5.0 +/– (5.0 * 0.2) or 5.0 +/– 20% of 5.0.

Parameters

Type: Float

Return

None

Scriptable

Yes

GetLightRadiusVariation

Returns the amount of random variation to apply to the light's radius.

Parameters

None

Return

Type: Float

Scriptable

Yes

SetLightIntensityVariation

Sets the amount of random variation to apply the Light component's diffuse and specular multipliers.

The Light component calculates the light intensity based on the duration of the lightning effect. This value is a percentage of that light intensity value. A value of 0.2 means that between –20% and 20% of the light intensity value is added back to the light's diffuse and specular multipliers.

For example, the light intensity is 10.0, and variation is 0.3; this means that the range of the light radius is: 10.0 +/– (10.0 * 0.3) or 10.0 +/– 30% of 10.0.

Parameters

Type: Float

Return

None

Scriptable

Yes

GetLightIntensityVariation

Returns the amount of random variation to apply the light's diffuse and specular multipliers.

Parameters

None

Return

Type: Float

Scriptable

Yes

SetParticleSizeVariation

Sets the amount of random variation to apply to the particle's size.

This variation is a percentage of the Particle component's Global size scale parameter. A value of 0.2 means that between –20% and 20% of the particle's global size value is added back to the size of the emitted particles.

For example, the particle size is 1.0, and variation is 0.5; the range of the light radius is: 1.0 +/– (1.0 * 0.5) or 1.0 +/– 50% of 1.0.

Parameters

Type: Float

Return

None

Scriptable

Yes

GetParticleSizeVariation

Returns the amount of random variation to apply to the particle's size.

Parameters

None

Return

Type: Float

Scriptable

Yes

SetLightningDuration

Sets how long the lightning strike lasts, in seconds. This value determines how long the lightning particle effect lasts. During this time, the sky highlight and light can continue to flash.

Parameters

Type: Double

Return

None

Scriptable

Yes

GetLightningDuration

Returns how long the lightning strike lasts, in seconds.

Parameters

None

Return

Type: Double

Scriptable

Yes

Request Bus Example Script

function example:OnActivate() LightningComponentRequestBus.Event.StartEffect(self.entityId) end