Verse Library verse

01 Device

Defines a game device class that continuously rotates a prop using an infinite loop and state tracking.

verse-library/verse-loops-to-repeat-actions-on-your-island/01-device.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Native }

# This is our main game manager class.
# It must inherit from creative_device so UEFN can run it.
disco_ball_device := class(creative_device):

    # This is our Prop Mover device.
    # Drag your DiscoBall Prop Mover onto this slot in the editor.
    @editable
    Mover : prop_mover_device = prop_mover_device{}

    # How many degrees to add on each loop tick.
    # Increase this number to spin faster.
    SpinStepDegrees : float = 5.0

    # Current accumulated rotation in degrees around the Z-axis (Yaw).
    var CurrentYaw : float = 0.0

    # OnBegin runs automatically when the game starts.
    # It is the entry point for our device.
    OnBegin<override>()<suspends> : void =
        RunSpinLoop()

    # This function contains the infinite spin loop.
    RunSpinLoop()<suspends> : void =
        # 'loop' repeats the block inside forever.
        # It is the correct Verse keyword for an infinite loop.
        loop:

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