Verse Library verse

01 Device

Implements the main script class for controlling storm behavior, including device references and movement logic.

verse-library/using-basic-storm-controller-devices-in-fortnite-creative/01-device.verse

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

# This is our script. It attaches to a device in the UEFN scene.
StormChaserScript := class(creative_device):

    # We need a reference to the storm device.
    # Think of this as "equipping" the storm in our script's inventory.
    # Drag your Basic Storm Controller into this slot in the Details Panel.
    @editable
    StormDevice : basic_storm_controller_device = basic_storm_controller_device{}

    # The maximum number of centimeters the storm center can shift per move.
    # Keeping this as a constant stops the storm from teleporting off the map.
    MaxOffset : float = 5000.0  # 5000 cm = 50 meters in Unreal units

    # OnBegin fires automatically when the game session starts.
    # <suspends> means this function is allowed to sleep/wait mid-execution.
    OnBegin<override>()<suspends> : void =
        MoveStormRandomly()

    # Packages the storm-movement logic into a reusable function.
    # Call this from OnBegin, a button event, or a loop—your choice.
    MoveStormRandomly() : void =
        # 1. Get the storm controller's current world transform,
        #    then read the translation vector as our "current position".
        CurrentTransform := StormDevice.GetTransform()
        CurrentPos := CurrentTransform.Translation

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