Verse Library verse

04 Device

Defines a hero device that smoothly interpolates a visual prop toward a target position on game start.

verse-library/verse-classes-and-structs-to-model-your-game-s-objects/04-device.verse

# This is the full color_chaser creative_device.
# It wires together the struct, the prop, and the logic.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Colors }
using { /UnrealEngine.com/Temporary/SpatialMath }

MyHeroInfo := struct:
    Name       : string
    HeroColor  : color

color_chaser := class(creative_device):

    # Wire this to a prop_device placed in the editor.
    MeshProp : prop_device = prop_device{}

    # Default hero data; override values in the editor
    # Details panel or change them in OnBegin below.
    var Info : MyHeroInfo = MyHeroInfo{
        Name      := "Builder",
        HeroColor := NamedColors.Red
    }

    OnBegin<override>()<suspends> : void =
        # Log the hero's name to the output window.
        Print("Hello, {Info.Name}!")

        # Move the prop to a target position as a demo.
        # Adjust the vector3 values for your island layout.
        MoveToTarget(vector3{X := 100.0, Y := 0.0, Z := 0.0})

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