Verse Library verse

01 Fragment

Uses trigger overlaps to find a spawner device and dynamically create cars for gameplay.

verse-library/car-racing-3-add-vehicles-in-unreal-editor-for-fortnite/01-fragment.verse

# We are creating a script attached to the Trigger device.
# "this" refers to the Trigger itself.
using {
    this
}

# This is our Function. Think of it as a custom move in your fighting game.
# We define it once, and call it later.
spawn_car := func():
    # 1. Find the Spawner device by its name in the editor.
    # 'Find' looks through the Scene Graph for an object named "Spawner_01".
    spawner := Find<Device>("Spawner_01")
    
    # Safety check: If we can't find the spawner, stop here.
    # This prevents the game from crashing if we made a typo.
    if (spawner == None):
        return

    # 2. Use the Spawner's built-in function to spawn the vehicle.
    # 'Spawn' is a method that comes with the Vehicle Spawner device.
    # It creates the car entity in the world.
    spawned_vehicle := spawner.Spawn()
    
    # 3. (Optional) Do something with the car immediately.
    # For example, we could lock the doors or set a timer.
    # Here, we just print a message to the debug console to prove it worked.
    Print("Car spawned! Ready for war.")

# This is an Event. Events are like ears that listen for specific actions.
# OnBeginPlay runs once when the game starts.

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