Verse Library verse

01 Fragment

Implements an NPC movement behavior struct with state flags and frame-by-frame position checking.

verse-library/verse-starter-template-1-creating-npc-behavior-in-unreal-editor-for-fortnite/01-fragment.verse

# This is the main script for our NPC's brain.
# It inherits from NPCBehavior, which means it has basic NPC powers.
struct SoldierBehavior : NPCBehavior {
    # VARIABLES: These are our "inventory slots."
    # TargetPosition is a Vector (X, Y, Z coordinates).
    # We start with it set to (0,0,0) until we give it an order.
    TargetPosition : vector = <0,0,0>
    
    # IsMoving is a boolean (True/False).
    # Like a light switch: on or off.
    IsMoving : bool = false
    
    # FUNCTION: This is our custom command.
    # When we call this, the NPC will start walking.
    MoveToTarget := func() {
        # Check if we are already moving.
        # If yes, do nothing (don't double up on orders).
        if (IsMoving) {
            return
        }
        
        # Set the flag to true. The NPC is now "busy."
        IsMoving = true
        
        # Tell the NPC to move to the stored TargetPosition.
        # This uses a built-in NPC function called 'Move'.
        Move(TargetPosition)
        
        # We'll add logic to stop later, but for now, it just walks!
    }

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