Verse Library verse

01 Standalone

Updates platform position each frame based on speed and time delta.

verse-library/creating-a-platformer-with-scene-graph-in-unreal-editor-for-fortnite/01-standalone.verse

# This is our main script file.
# It defines a component for our platform.

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

# We create a new type called MovingPlatform.
# This is our "Component" definition.
MovingPlatform := class(Component):

    # This is the speed of movement.
    # It is a constant value.
    MovementSpeed := 100.0

    # This function runs every frame.
    # It updates the platform's position.
    OnUpdate := func(event: UpdateEvent):
        # Get the current position of the entity.
        current_pos := GetTransform().Location

        # Calculate the new position.
        # We move it up or down based on time.
        new_y := current_pos.Y + (MovementSpeed * event.DeltaTime)

        # Create the new transform.
        new_transform := Transform{
            Location: Vector{
                X: current_pos.X,
                Y: new_y,
                Z: current_pos.Z

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