Verse Library verse

01 Fragment

Component that spawns random game props at a specified offset when a boolean trigger condition is met.

verse-library/creating/01-fragment.verse

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

# This is our "Component" definition.
# It tells the engine what data this script needs.
ChaosButtonComponent := component (
    # We need a reference to the world to spawn things
    World: world,
    # We need a reference to the transform (position/rotation) of this component
    Transform: transform,
    # A simple flag to know if the button was pressed
    ButtonPressed: bool = false
)

# This is the main function. Think of it as the "Brain" of the component.
# It runs every time the game checks in (or when we tell it to).
main := func (component: ChaosButtonComponent) -> void:
    # Check if the button has been pressed
    # In a real device, we'd link this to an event, but for this demo,
    # we'll simulate a press via a simple trigger logic below.
    
    # If the button is pressed, we spawn a prop
    if component.ButtonPressed == true:
        # 1. Get the current position of the button
        CurrentLocation := component.Transform.GetLocation()
        
        # 2. Move it up by 200 units (so it doesn't spawn inside the button)
        SpawnLocation := CurrentLocation + vec(0, 0, 200)
        
        # 3. Pick a random prop type (Barrel, Crate, or Turret)

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