Home Forums Verse Code Custom Fiend, Custom Enemy, Custom Creature – Verse Code

Tagged: , , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #32
    Tyson STyson S
    Keymaster

    Tips to make this work:

    • Turn your static mesh into a building prop for this to work.
    • Depending on the mesh you chose, you may need to change the pivot of your mesh
    • Most likely you’ll have to mess with the “ZOffset” float to get the prop to “walk” on the ground
    • You’ll also want to change any settings you’d like to the creature spawner (e.g. choose your creature type to make it harder or easier to eliminate)

    Here’s the full code

    using { /Fortnite.com/Devices }
    
    using { /Fortnite.com/Characters }
    
    using { /Verse.org/Simulation }
    
    using { /UnrealEngine.com/Temporary/Diagnostics }
    
    using { /UnrealEngine.com/Temporary/SpatialMath }
    
    using { /Fortnite.com/Game }
    
    # ██╗     ██╗    ██╗   ██╗██╗███████╗██╗   ██╗ █████╗ ██╗    
    # ██║     ██║    ██║   ██║██║██╔════╝██║   ██║██╔══██╗██║    
    # ██║     ██║    ██║   ██║██║███████╗██║   ██║███████║██║    
    # ██║     ██║    ╚██╗ ██╔╝██║╚════██║██║   ██║██╔══██║██║    
    # ███████╗███████╗╚████╔╝ ██║███████║╚██████╔╝██║  ██║███████╗
    # ╚══════╝╚══════╝ ╚═══╝  ╚═╝╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝
    
    # VERSE SCRIPT
    
    # Author: Logan Lewis
    
    # Follow me on Twitter.com/X.com @LL_Visuals
    
    # Discord: llvisual
    
    # A device that replaces the Fortnite "Fiends" with a custom skeletal mesh of choice
    
    # TO-DO: Drag your "CustomFiend" Verse device into your level, then inside the details panel, add your Prop, CreatureSpawner, and VFX
    
    CustomFiend := class(creative_device):
    
        # Needs to be initialized as an asset, so that SpawnProp can work, can/will be changed into a creative_prop later
    
        @editableProp: creative_prop_asset=DefaultCreativePropAsset
    
        @editable CreatureSpawner : creature_spawner_device = creature_spawner_device {}
    
        @editable EliminationVFX : vfx_spawner_device = vfx_spawner_device {}
    
        @editable ZOffset : float = -2.0
    
        OnBegin<override>()<suspends>:void=
    
            # Subscribing to the creature_spawner_device SpawnedEvent, calling for FiendSpawned Function and sending the agent that spawned          
    
            CreatureSpawner.SpawnedEvent.Subscribe(FiendSpawned)
    
        FiendSpawned(Agent: agent):void=
    
            # Grabbing the agent from the Spawned Event and grabbing the associated fort_character
    
            if (FortCharacter := Agent.GetFortCharacter[]):
    
                # Hiding FortCharacter, making the Fiend invisible
    
                FortCharacter.Hide()
    
                # Adjusting the height of the prop to ensure it spawns at ground level
    
                Transform := FortCharacter.GetTransform()
    
                AdjustedTranslation := vector3{
    
                    X := Transform.Translation.X,
    
                    Y := Transform.Translation.Y,
    
                    Z := Transform.Translation.Z + ZOffset
    
                }
    
                # Initializing local variable to be our SpawnedPropResult, also passing in the (Asset , Position, Rotation) for SpawnProp
    
                SpawnedPropResult := SpawnProp(Prop, AdjustedTranslation, Transform.Rotation)
    
                # SpawnedProp gives us a "?creative_prop" but we want a creativeprop, there's a few ways this can be written
    
                # In this example I'm unwrapping the optional type within this failable function
    
                if (SpawnedProp := SpawnedPropResult(0)?):
    
                    spawn:
    
                        # Spawning an async function, passing in the FortCharacter and SpawnedProp
    
                        FollowFiend(FortCharacter , SpawnedProp)
    
        FollowFiend(FortCharacter: fort_character , SpawnedProp: creative_prop)<suspends>:void=
    
            # Starting a loop
    
            loop:
    
                # Checking to see if the FortCharacter is Active within the game session
    
                # If the fiend is eliminated, this will result in Moving into line 36
    
                # If the fiend is active, i.e. still alive, the loop will move to line 40
    
                if (not FortCharacter.IsActive[]):
    
                    # Getting rid of the spawnedprop, we do this for garbage collection and to mimic the elimination of the fiend
    
                    SpawnedProp.Dispose()
    
                    # Triggering the elimination VFX
    
                    VFXTransform := FortCharacter.GetTransform()
    
                    VFXTransform.Translation.Z + ZOffset
    
                    if (EliminationVFX.TeleportTo[VFXTransform]):
    
                        EliminationVFX.Enable()
    
                        EliminationVFX.Restart()
    
                    # ending the loop
    
                    break
    
                # Adjusting the height of the spawned prop to stay at ground level
    
                Transform := FortCharacter.GetTransform()
    
                AdjustedTranslation := vector3{
    
                    X := Transform.Translation.X,
    
                    Y := Transform.Translation.Y,
    
                    Z := Transform.Translation.Z + ZOffset
    
                }
    
                # Moving the Spawned Prop to (Transform, Rotation, every 0.1)
    
                SpawnedProp.MoveTo(AdjustedTranslation, Transform.Rotation, 0.1)

    Insert stuff here

    How to Use

    Here’s a step-by-step guide on how to use this custom Fiend device in UEFN:

    1. Initial Setup:
      • Add the “CustomFiend” Verse device to your Fortnite Creative map
      • Create or obtain the custom prop you want to use as your Fiend’s appearance
      • Place a Creature Spawner device in your map (this will spawn the actual Fiends)
      • Place a VFX Spawner device (this will create effects when Fiends are eliminated)
    2. Configure the Device:
      • Select the CustomFiend device
      • In the device’s details panel, you need to link three things:
        • Add your custom prop in the “Prop” field
        • Link your Creature Spawner device
        • Link your VFX Spawner device
      • Optionally adjust the “ZOffset” value if your prop needs to be raised or lowered (-2.0 is the default)
    3. Configure the Creature Spawner:
      • Set up your Creature Spawner device as you normally would for regular Fiends
      • Adjust spawn rates, health, damage, and other Fiend settings in the Creature Spawner

    After setup, when you start the game:

    • The Creature Spawner will create and spawn Fiends instead of the default Fortnite creatures
    • The Fiends will be invisible but maintain their normal behavior
    • Your custom prop will appear in place of each Fiend and follow their movement
    • When players eliminate the Fiends, your chosen VFX effect will play

    About This Verse Code Snippet

    The code provides a custom device that essentially replaces the default Fortnite “Fiends” (zombie-like creatures) with custom skeletal meshes/props while maintaining the original Fiend’s behavior. Here’s how it works:

    1. The CustomFiend class takes three main editable inputs:
      • A custom prop asset (the visual replacement for the Fiend)
      • A creature spawner device (spawns the original Fiends)
      • A VFX spawner device (for visual effects when the Fiend is eliminated)
    2. The main workflow is:
      • When a Fiend spawns from the creature spawner, it triggers the FiendSpawned function
      • The original Fiend character is hidden using FortCharacter.Hide()
      • A custom prop is spawned in its place, with an adjustable Z-offset (height adjustment)
      • The code then continuously updates the custom prop’s position to match the hidden Fiend’s movement
    3. When the Fiend is eliminated:
      • The custom prop is removed
      • An elimination VFX effect is played at the location
      • The tracking loop ends

    This is a clever way to create custom-looking enemies while maintaining the original Fiend’s AI behavior and game mechanics. It could be used to create more visually diverse enemies or themed creatures that fit specific map designs.

    #67
    James StevensJames Stevens
    Participant

    1st!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Comments are closed.

Close Search Window