Hello,
i am trying to make a game mode where you have to get items from different “capture_item_spawner_device”, in a random order, and bring them back to a “capture_area_device”. Everything works just fine, but the first time only… if i push my verse code, try the game, it works. If i stop the game in fortnite, then start the game again, everything is working except this function who never put the player in stasis:
ItemIsDelivered<private>(InPlayer : agent) : void=
if (ItemGranter := ItemGranters[CurrentItem]):
ItemGranter.Disable()
set CurrentItem += 1
if (CurrentItem < TotalItemsToCapture):
EnableCurrentItemGranter()
else:
CaptureArea.Disable()
PickupMarker.MapIndicator.DeactivateObjectivePulse(InPlayer)
if (FortChar := InPlayer.GetFortCharacter[]):
FortChar.PutInStasis(stasis_args{AllowFalling := true})
#EndGameDevice.Activate(InPlayer)
here is the full code (I made it in a single verse file for testing, I will cleanup later)
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /Verse.org/Verse }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Devices/CreativeAnimation }
using { /Fortnite.com/Characters }
game_manager := class(creative_device):
var TotalItemsToCapture : int = 0
var CurrentItem : int = 0
var PlayerOpt<private> : ?player = false
@editable
var ItemGranters : []capture_item_spawner_device = array{}
@editable
CaptureArea : capture_area_device = capture_area_device{}
@editable
EndGameDevice : end_game_device = end_game_device{}
@editable
PickupMarker<public> : objective_marker = objective_marker{}
OnBegin<override>()<suspends>:void=
Reset()
FindPlayer()
StartListen()
EnableCurrentItemGranter()
EnableMapIndicator();
StartListen<private>() : void=
CaptureArea.ItemIsDeliveredEvent.Subscribe(ItemIsDelivered)
for (ItemGranter : ItemGranters):
ItemGranter.ItemPickedUpEvent.Subscribe(ItemPickedUp);
EnableMapIndicator<private>() : void=
if (FoundPlayer := PlayerOpt?):
PickupMarker.MapIndicator.ActivateObjectivePulse(FoundPlayer)
ItemPickedUp<private>(InPlayer : agent) : void=
if (FoundPlayer := PlayerOpt?):
Transform := CaptureArea.GetTransform()
if (PickupMarker.RootProp.TeleportTo[Transform.Translation, Transform.Rotation]) {}
PickupMarker.MapIndicator.ActivateObjectivePulse(FoundPlayer)
Reset<private>() : void=
set TotalItemsToCapture = ItemGranters.Length
set CurrentItem = 0
set ItemGranters = Shuffle(ItemGranters)
EnableCurrentItemGranter<private>() : void=
if (ItemGranter := ItemGranters[CurrentItem]):
ItemGranter.Enable()
Transform := ItemGranter.GetTransform()
if (PickupMarker.RootProp.TeleportTo[Transform.Translation, Transform.Rotation]) {}
ItemIsDelivered<private>(InPlayer : agent) : void=
if (ItemGranter := ItemGranters[CurrentItem]):
ItemGranter.Disable()
set CurrentItem += 1
if (CurrentItem < TotalItemsToCapture):
EnableCurrentItemGranter()
else:
CaptureArea.Disable()
PickupMarker.MapIndicator.DeactivateObjectivePulse(InPlayer)
if (FortChar := InPlayer.GetFortCharacter[]):
FortChar.PutInStasis(stasis_args{AllowFalling := true})
#EndGameDevice.Activate(InPlayer)
FindPlayer<private>() : void =
AllPlayers := Self.GetPlayspace().GetPlayers()
if (FirstPlayer := AllPlayers[0]):
Print("player found")
set PlayerOpt = option{FirstPlayer}
else:
Print("player not found")
objective_marker<public> := struct<concrete>:
# The prop that will be moved
@editable
RootProp<public> : creative_prop = creative_prop{}
# The child of the prop that will move with it
@editable
MapIndicator<public> : map_indicator_device = map_indicator_device{}
Also my code may be ■■■■, if you have some advices it will be appreciated.
thanks.