VerseIsland
Feed Learn Leaderboard Guides Reference Explore Search Docs Verse Library
Sign in
Feed Learn 📖 Codex Leaderboard Guides Reference Explore Search Docs Verse Library
UEFN › Building & Props · Up to UEFN · Building & Props · 69 of 71 in Building & Props
Browse UEFN

Adding the Full Script

6. Adding the Full Script

This section includes the complete code to add to the Verse files you created.

This section includes the complete code to add to the Verse files you created.

Complete Code

There are multiple Verse files in this project.

  • heartbeat.verse: See below for the file’s complete code.
  • base_team.verse: See below for the file’s complete code.
  • hunter_team.verse: See below for the file’s complete code.
  • prop_team.verse: See below for the file’s complete code.
  • round_timer.verse: See below for the file’s complete code.
  • waiting_for_more_players.verse: See below for the file’s complete code.

heartbeat.verse



|  | using { /Fortnite.com/Characters } |
| --- | --- |
|  | using { /Fortnite.com/Devices } |
|  | using { /Fortnite.com/UI } |
|  | using { /UnrealEngine.com/Temporary/SpatialMath } |
|  | using { /UnrealEngine.com/Temporary/Diagnostics } |
|  | using { /UnrealEngine.com/Temporary/UI } |
|  | using { /Verse.org/Colors } |
|  | using { /Verse.org/Simulation } |
|  |  |
|  | log_heart_beat := class(log_channel){} |
|  |  |
|  | # These messages are used to notify a prop agent with a message (or to hide it) when they need to move to avoid their heartbeat from becoming visible. |
|  | HeartBeatWarningMessage<localizes>(Time:int):message = "Heart Beat in {Time} Seconds. Move!" |
|  | HeartBeatWarningClear<localizes>:message = "" |
|  |  |
|  | # This class exposed the editable properties for the heartbeat to the prop_hunt device. |
|  | heart_beat := class<concrete>(): |
|  | Logger:log = log{Channel:=log_heart_beat} |
|  |  |
|  | @editable # The number of seconds before a prop agent must move before the heartbeat reveals their position. |
|  | MoveTime:float = 15.0 |
|  |  |
|  | @editable # The seconds remaining before the heartbeat warning appears. Shouldn't be > than HeartBeatTimer. |
|  | WarningTime:float = 5.0 |
|  |  |
|  | @editable # An array of heartbeat VFX devices. There is one per player. |
|  | AgentVFX:[]heartbeat_vfx = array{} |
|  |  |
|  | @editable # The audio player device used to play the heartbeat sound effects (SFX). |
|  | SFXPlayer:radio_device = radio_device{} |
|  |  |
|  | # This map associates a UI for displaying the heartbeat warning to each prop agent. |
|  | var WarningUI:[agent]heartbeat_warning_ui = map{} |
|  |  |
|  | # Keeps track of how many players have an active heartbeat so we can manage the SFX device. |
|  | var NumberOfHeartBeats:int = 0 |
|  |  |
|  | # Sets up heartbeat UI for the agent. |
|  | SetUpUI(PropAgent:agent):void = |
|  | if: |
|  | not WarningUI[PropAgent] |
|  | AsPlayer := player[PropAgent] |
|  | PlayerUI := GetPlayerUI[AsPlayer] |
|  | then: |
|  | UIData:heartbeat_warning_ui = heartbeat_warning_ui{} |
|  | UIData.CreateCanvas() |
|  | PlayerUI.AddWidget(UIData.Canvas, player_ui_slot{ZOrder := 1}) |
|  | if (set WarningUI[PropAgent] = UIData) {} |
|  |  |
|  | # Activates the heartbeat VFX and SFX for the specified player. |
|  | Enable(PropAgent:agent, HeartBeatVFXData:heartbeat_vfx):void = |
|  | if: |
|  | # Get the character, which is used to find the prop agent's position in the scene. |
|  | Character := PropAgent.GetFortCharacter[] |
|  | then: |
|  |  |
|  | # Set the heartbeat VFX's position to the prop agent's position. |
|  | HeartBeatVFXData.Activate(Character.GetTransform()) |
|  |  |
|  | # Increment the heartbeat count, and if this is the first heartbeat playing, we need to play the audio to get it started. |
|  | set NumberOfHeartBeats += 1 |
|  | if (NumberOfHeartBeats = 1) then SFXPlayer.Play() |
|  |  |
|  | # Register the prop agent to the audio player device so the heartbeat audio will play from that position. |
|  | SFXPlayer.Register(PropAgent) |
|  | else: |
|  | Logger.Print("Character, Index, or HeartBeatVFXData not found. Cannot start the heartbeat") |
|  |  |
|  | # Clears the heartbeat VFX and SFX for the specified prop agent. |
|  | Disable(PropAgent:agent, HeartBeatVFXData:heartbeat_vfx):void = |
|  | Logger.Print("Disabling heart beat.") |
|  |  |
|  | # Deactivate the VFX visuals. |
|  | HeartBeatVFXData.Deactivate() |
|  |  |
|  | # Unregister the prop agent from the audio player device, causing the heartbeat audio to stop. |
|  | SFXPlayer.Unregister(PropAgent) |
|  |  |
|  | # Decrement the heartbeat counter. This counter should never drop below 0. |
|  | set NumberOfHeartBeats -= 1 |
|  | if (NumberOfHeartBeats < 0) then set NumberOfHeartBeats = 0 |
|  |  |
|  | # Clears all heartbeat VFX and SFX for all prop agents. |
|  | DisableAll():void = |
|  | Logger.Print("Disabling all heart beats.") |
|  |  |
|  | # Iterate through all VFX and move them to 0,0,0. |
|  | for (HeartBeatVFXDevice : AgentVFX): |
|  | HeartBeatVFXDevice.Deactivate() |
|  |  |
|  | # Unregister all players from the heart beat audio. |
|  | SFXPlayer.UnregisterAll() |
|  |  |
|  | # Reinitialize the heartbeat counter to 0 |
|  | set NumberOfHeartBeats = 0 |
|  |  |
|  | # The heartbeat_warning_ui class contains a struct of data to track the UI canvas and text_block per player as well as the function to create a new heartbeat warning UI canvas. |
|  | heartbeat_warning_ui := class: |
|  | var Canvas:canvas = canvas{} |
|  | var Text:text_block = text_block{} |
|  |  |
|  | # Creates the UI canvas for the warning message. |
|  | CreateCanvas():void = |
|  | set Text = text_block{DefaultTextColor := NamedColors.White, DefaultShadowColor := NamedColors.Black} |
|  | set Canvas = canvas: |
|  | Slots := array: |
|  | canvas_slot: |
|  | Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.75}, Maximum := vector2{X := 0.5, Y := 0.75}} |
|  | Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0} |
|  | Alignment := vector2{X := 0.5, Y := 1.0} |
|  | SizeToContent := true |
|  | Widget := Text |
|  |  |
|  | # The heartbeat_vfx class contains a struct of data to track the VFX's root and vfx_spawner_device objects per player as well as the functions to set the VFX to a position or reset it. |
|  | heartbeat_vfx := class<concrete>: |
|  |  |
|  | @editable # The VFX device for each heart beat. |
|  | VFXDevice:vfx_spawner_device = vfx_spawner_device{} |
|  |  |
|  | # This offset is used to position the heartbeat above a prop agent's head. |
|  | HeartBeatVFXOffset:vector3 = vector3{X := 0.0, Y := 0.0, Z := 110.0} |
|  |  |
|  | # Sets the position of the heartbeat VFX and then enables the VFX. |
|  | Activate(Transform:transform):void = |
|  | VFXPosition := Transform.Translation + HeartBeatVFXOffset |
|  | if (VFXDevice.TeleportTo[VFXPosition, Transform.Rotation]): |
|  | VFXDevice.Enable() |
|  |  |
|  | # Disables the VFX, hiding the heartbeat visuals. |
|  | Deactivate():void = |
|  | VFXDevice.Disable() |

You're reading a preview

The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.

Sign in with Discord — free for members Read the original at Epic Games

Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in
    📄
    Source
    Epic Games

    © Epic Games. Official Epic developer documentation, shown here as a reference with a link to the original. All rights remain with Epic Games. Terms ↗

    View original Sources & licensing
    Request removal
    Last updated Dec 5, 2024
    Keep exploring
    More in Building & Props · 69 of 71
    Prev
    verse prop hunt template 5 game loop and round management in unreal editor for fortnite
    Next
    verse prop hunt template 7 designing your island in unreal editor for fortnite
    Browse all files in this folder (A–Z)
    Next up
    • Use your creativity to design your island.
    Related topics
    • Verse Prop Hunt Template 10 Customizing The Gameplay In Unreal Editor For Fortnite Building & Props
    • Verse Prop Hunt Template 1 Creating A New Project In Unreal Editor For Fortnite Building & Props
    • Verse Starter Template 4 Representing Command Data In Unreal Editor For Fortnite Tutorials
    • Verse Prop Hunt Template 9 Configuring The Informative Devices In Unreal Editor For Fortnite Devices
    • Verse Prop Hunt Template 2 Playing Visual Effects In Unreal Editor For Fortnite Building & Props

    Related

    Open in graph →

    Related topics

    • Verse Prop Hunt Template 10 Customizing The Gameplay In Unreal Editor For Fortnite
    • Verse Prop Hunt Template 1 Creating A New Project In Unreal Editor For Fortnite
    • Verse Starter Template 4 Representing Command Data In Unreal Editor For Fortnite
    • Verse Prop Hunt Template 9 Configuring The Informative Devices In Unreal Editor For Fortnite
    • Verse Prop Hunt Template 2 Playing Visual Effects In Unreal Editor For Fortnite
    VerseIsland · an archipelago of Verse & UEFN knowledge
    🗺️ Island atlas Learn Guides History About & Press Sources & Licensing Status

    Not affiliated with Epic Games. Fortnite, UEFN, Unreal Engine, and Verse are trademarks of Epic Games, Inc. Content is attributed to its source — see Sources & Licensing.

    🦜

    Scout · your island guide

    The Isle of Verse