Verse Library verse

01 Device

Smoothly pulses a light's brightness using a sine wave calculation.

verse-library/light-effects/01-device.verse

using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
using { /Verse.org/Colors }

# This is our main script block
PulsingLightDevice := class(creative_device):

    # This is a 'public' variable.
    # It means the light in the editor can be linked here.
    @editable
    LightDevice : customizable_light_device = customizable_light_device{}

    # This function runs when the game starts
    OnBegin<override>()<suspends> : void =
        # We start our timer at 0.0
        var Time : float = 0.0

        # This loop runs forever until the game stops
        loop:
            # We use 'Sin' to create a wave.
            # It goes up and down smoothly.
            Wave := Sin(Time * 5.0)

            # We map the wave (-1.0 to 1.0) to a 0.0–1.0 range
            # so the light never goes negative.
            Brightness := (Wave + 1.0) / 2.0

            # We set the light's color to a red pulse.

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in