Verse Library verse

01 Device

Checks player distance and hides distant objects to optimize performance, supplementing automatic HLOD simplification.

verse-library/world-partition-hierarchical-level-of-detail/01-device.verse

# This is a simplified example of how Verse interacts with scene objects.
# Note: Actual HLOD generation is an editor-side tool, not a runtime Verse function.
# This script shows how you might manage object visibility based on distance,
# mimicking the *effect* of HLODs for dynamic objects.

using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/VerseTypes }

# Define our "Tree" device
HLOD_Tree_Device := class(creative_device):
    # A variable to store the distance threshold
    # Think of this as the "Zoom Level" where the tree simplifies
    LOD_Threshold: float = 1000.0 # Units away

    OnBegin<override>()<sidescript>:
        # When the game starts, we don't do anything yet.
        # HLODs are pre-generated by the editor.
        pass

    # This event fires every frame
    OnUpdate<override>()<sidescript>:
        # Get the list of players
        players := GetPlayers()

        for player in players:
            # Get player's location
            player_loc := player.GetLocation()

            # Get this tree's location
            tree_loc := GetLocation()

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