Verse Library verse

01 Fragment

Defines an interactive actor class that reveals a portal mesh when a player touches it.

verse-library/mystic-portal-3-create-portal-material-in-unreal-editor-for-fortnite/01-fragment.verse

# This is a simple Verse script for the portal
# It makes the portal appear when a player is close

using { /Fortnite.com/Devices }
using { /Verse.org/Sim }

# We define a device called MysticPortal
# This device holds our portal logic
actor class MysticPortal is Interactor {
    # This is a variable for the portal mesh
    # A variable is a box that holds data
    PortalMesh : StaticMeshComponent = nil

    # This function runs when the game starts
    OnBegin<override>()<suspends> {
        # We find the mesh in the level
        # We get it from the World
        PortalMesh = World::GetWorld().GetActors()[0]
    }

    # This function runs when a player touches us
    OnInteract<override>(Other : Actor) {
        # We check if the other actor is a Player
        if (Other:IsA<Player>()) {
            # We make the portal visible
            # This is like turning on a light
            PortalMesh.SetVisibility(true)
        }
    }
}

Comments

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