Verse Library verse

01 Fragment

Activates a physics tree to fall when a button is pressed and checks if it lands safely.

verse-library/using-physics-tree-devices-in-fortnite-creative/01-fragment.verse

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

# This is our main script.
# It watches the tree and the button.
class MyTreeScript is WorldDevice():

    # This is the tree device.
    # We will link it in the editor.
    TreeDevice: physics_tree_device = physics_tree_device()

    # This is the button player steps on.
    # We will link it in the editor too.
    TriggerButton: button_device = button_device()

    # This runs when the game starts.
    OnBegin<override>()<suspends>: void =
        # We listen for when the button is pressed.
        TriggerButton.PressedEvent.Subscribe(SimulateFall)

    # This function makes the tree fall.
    SimulateFall(): void =
        # We tell the tree to start falling.
        # It will now obey gravity.
        TreeDevice.Fall()
        
        # We wait a little bit.
        # This gives time for the tree to move.
        Wait(2.0)

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