I have the following statement that does not work:
OnBegin():void=
AllPlayers := GetPlayspace().GetPlayers()
if(Player1Stasis := AllPlayers[0].GetFortCharacter):
Player1Stasis.PutInStasis(stasis_args{})
it does not work, but if I add a Sleep(0.0) before the statement it does work, is this a defect?
OnBegin():void=
Sleep(0.0)
AllPlayers := GetPlayspace().GetPlayers()
if(Player1Stasis := AllPlayers[0].GetFortCharacter):
Player1Stasis.PutInStasis(stasis_args{})
Steps to Reproduce
above
Expected Result
your player goes into stasis on the game start
Observed Result
it does not work unless you add a sleep with 0 value
If players happen to be already in stasis, it will not work I suspect.
Can you print AllPlayers.Length to see if you have any players on begin?
Sleep helps you delay the moment you attempt stasis, so by the time you run it you already have players or their short stasis is already over so you can put them in stasis again.
You might want to use certain events and put this logic in your OnSomeEvent function and also you might want to check if player is in stasis or not before attempting.
Wow thank you! I was racking my brain trying to figure out why only 1 of my characters was getting frozen when I was trying to freeze both.
Sleep(0.0) saved the day!