Hi Everyone,
I am close to publishing a game where players can score goals. After the goal, there is a short pause where the scoring player can run around and celebrate. When that period is over, all players should respawn.
It works fine in UEFN Edit/Live Sessions with the other contributor on my team and I testing. In the UEFN session, both players are eliminated prompting them to respawn at the same time and resume play.
However, when I publish the island (it is unlisted now), only the player that scores the goal is the one that respawns, and I cannot figure out why. I don’t think it will help, but the island code is: 4195-8467-3857. You’ll really need two players to see the bug. Note that once you get the ball, you’ll have to press what is likely your zoom button (right mouse click) to charge up a shot.
I have hundreds of hours into this at this point. I’ve debugged a LOT of stuff in my time. But when there’s different behaviors between dev and prod environments with no error codes, it really puts the developer in a bad spot. I simply have no idea what to do other than to beg for help.
Below is the relevant code. Note that for EliminateAllPlayers
. Note I have tried versions of that function with suspend, without suspend. And I also have tried versions with Sleep functions sprinkled around to wait for the call stack to clear between instructions. Nothing seems to make a difference when published.
Thanks in advance!
# Handle post goal functions and setup up the next round
PostGoal(Agent:agent, ScoringTeamIndex: int)<suspends>:void=
# Print("PostGoal executed")
DisableBallTrigger.Trigger()
BallRespawnTimer.Reset()
GameTimer.Pause()
set IsCelebratingGoal = true
# Stasis args
NonScoringStasisArgs : stasis_args = stasis_args{ AllowTurning:= false, AllowEmotes:= false, AllowFalling:= true }
ScoringStasisArgs : stasis_args = stasis_args{ AllowTurning:= true, AllowEmotes:= true, AllowFalling:= true }
Players := GetPlayspace().GetPlayers()
for(Player: Players, FC := Player.GetFortCharacter[]):
if:
ScoringAgent := PreviousPlayerWithBall?
ScoringFC := ScoringAgent.GetFortCharacter[]
ScoringAgent = FC.GetAgent[]
then:
ChangePlayerSpeed(Player, "normal")
else:
FC.PutInStasis(NonScoringStasisArgs)
set PreviousPlayerWithBall = false
set PlayerWithBall = false
Sleep(10.0) # Celebration time
spawn{EliminateAllPlayersAsync()}
Sleep(6.0) # Sleep for 6 seconds (respawn timer)
State.SetPlayerWithBall(false)
RoundStart() # Start the round
EliminateAllPlayers()<suspends>:void =
Players := GetPlayspace().GetPlayers()
for(Player: Players, FC := Player.GetFortCharacter[]):
FC.SetVulnerability(true)
FC.SetHealth(99.9)
FC.Damage(99.9)