hey, i started to learn verse and one of my biggest problems: How to make the things works in multiplayer, in this case, i created a hud to count how many trees i breaked, and its works very greate in solo, but when other player joins, the hud don’t works correctly
btw: i’m very newbie at coding and verse is my first language, so, i will be glad if you can explain this like if i have 5 years
Here is my code
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }
using{ /Verse.org/Simulation/Tags }
using { /Verse.org/Colors }
BreakedTreesHUD := class(creative_device):
@editable
TreeManipulator :prop_manipulator_device = prop_manipulator_device{}
var BreakedTrees: int = 0
SetDynamicText<localizes> (Value:string): message = "{Value}"
SetDynamicTextLevel<localizes> (Value:string): message = "{Value}"
var PlayerXP: float = 0.0
var BreakedTreesTextBlock: text_block = text_block{DefaultTextColor:=NamedColors.White, DefaultShadowColor:=NamedColors.Black, DefaultShadowOffset:=option{vector2{X:=3.0, Y:=2.0}}}
var RockLevelTextBlock: text_block = text_block{DefaultTextColor:=NamedColors.Black}
var BreakedTreesColorBlock: color_block = color_block{DefaultColor:=NamedColors.Yellow}
var ResizedColorBlock: color_block = color_block{DefaultColor:=NamedColors.Yellow}
var XColorBlockPosMin: float = 0.0
var XColorBlockPosMax: float = 0.2
var FloatAddX: float =0.2
var TheRockScale: vector3 = vector3{}
CreatedUI : logic = false
OnPlayerBreakTree(Agent:agent):void=
set BreakedTrees+=1
UpdatePlayerUI(Agent)
CreatedUIMethod(TextBlock: text_block):canvas=
UICanvas: canvas = canvas:
Slots:= array:
canvas_slot:
Anchors:= anchors{Minimum:= vector2{X:=0.5, Y:=0.13}, Maximum:= vector2{X:=0.5, Y:=0.13}}
Alignment:=vector2{X:=0.5, Y:=0.5}
Widget:= TextBlock
Offsets:=margin{Top:=0.0, Left:=0.0, Right:=0.0, Bottom:=0.0}
return UICanvas
UpdatePlayerUI(Agent:agent):void=
if(Player:player = player[Agent]):
if(PlayerUI:=GetPlayerUI[Player]):
if(CreatedUI=false):
ScoreWidget:= CreatedUIMethod(BreakedTreesTextBlock)
PlayerUI.AddWidget(ScoreWidget)
BreakedTreesTextBlock.SetText(SetDynamicText("Wood:{BreakedTrees}"))
else:
BreakedTreesTextBlock.SetText(SetDynamicText("Wood:{BreakedTrees}"))
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
TreeManipulator.DestroyedEvent.Subscribe(OnPlayerBreakTree)