【UEFN】How to use the Score Manager in Verse

Eisuke Kawano
3 min readJan 21, 2024

--

Background

When I was thinking about starting to create a game on UEFN, I wanted to create something that would allow players to compete with other players using scores. At the time, I had not touched Verse and could not get around to it because it had to be set up on the GUI and involved a variety of devices.
Recently, I have been writing about Verse and have an idea of how to use it, so I would like to write about it.

What the score_manager_device class can do

  • Receive a signal when a trigger is pressed the maximum number of times
  • Receive a signal when a score is added (can be done per player)
  • Toggle between active and inactive
  • Reset score status back to reset (can be done per player)
  • Let the score be earned
  • Increase the amount of score you receive by 1 (can be done per player)
  • Decrease the amount of score you receive by 1 (can be done per player)
  • Change the amount of score you receive by specifying a number (can be done on a per-player basis)
  • Add the amount of the current score to the score (can be done per player)
  • Get the current score (can be done on a per player basis)

Implementation

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

score_trigger_device := class(creative_device):

@editable
Trigger:trigger_device=trigger_device{}
@editable
ScoreManager:score_manager_device=score_manager_device{}
@editable
ScoreText:billboard_device=billboard_device{}
@editable
EventText:int=10

ScoreMessage<localizes>(msg:string):message="{msg}"

OnBegin<override>()<suspends>:void=
SetTriggerText(0)
# Specify and change the maximum number of triggers
Trigger.SetMaxTriggerCount(10)
# Change the amount of score you receive by specifying a number.
ScoreManager.SetScoreAward(10)
Trigger.TriggeredEvent.Subscribe(OnIncrementTrigger)
# Receive signals when scores are added
ScoreManager.ScoreOutputEvent.Subscribe(OnScoreOutput)
# Receive a signal when the trigger is pressed the maximum number of times
ScoreManager.MaxTriggersEvent.Subscribe(OnMaxTriggers)

OnIncrementTrigger(QAgent:?agent):void=
if (Agnet:=QAgent?):
# Add to your score the amount of score you currently receive.
ScoreManager.Activate(Agnet)
# Increase the amount of score you receive by 1
ScoreManager.Increment(Agnet)
SetTriggerText(ScoreManager.GetCurrentScore(Agnet))

OnDecrementTrigger(QAgent:?agent):void=
if (Agnet:=QAgent?):
# Add to your score the amount of score you currently receive.
ScoreManager.Activate(Agnet)
# Reduce the amount of score you get by 1
ScoreManager.Decrement(Agnet)
# Get the amount of score you get
Award:=ScoreManager.GetScoreAward()
Print("Award : {Award}")
SetTriggerText(ScoreManager.GetCurrentScore(Agnet))

OnScoreOutput(Agent:agent):void=
Print("Score Output")

OnMaxTriggers(QAgent:agent):void=
Print("Max Triggers Reached")

SetTriggerText(value:int):void=
ScoreText.SetText(ScoreMessage("Now Socre : {value}"))

OnEnableAndDisable():void=
# Enable Add Score
ScoreManager.Enable()
# Disable score addition
ScoreManager.Disable()

It looks like it could be detailed for each player.

On receiving a signal when a trigger is pressed the maximum number of times

        # Specify and change the maximum number of triggers
Trigger.SetMaxTriggerCount(10)

# Receive a signal when the trigger is pressed the maximum number of times
ScoreManager.MaxTriggersEvent.Subscribe(OnMaxTriggers)

The maximum number of triggers is specified above, and MaxTriggersEvent reacts when the specified number is reached.

Summary

Tycoon games, which are common in UEFN, would be easier if they could be handled in Verse like this.
Personally, I think it is easier to use the score manager in Verse than in GUI.

--

--