Putting players in stasis doesn't work on a frame where the player fires their weapon

Summary

fort_character.PutInStasis() has no effect if it is called on a frame in which the player damaged or destroyed certain objects with a hitscan weapon. This problem happens if the call to PutInStasis() is done in response to receiving a DamagedEvent on an objective device, or an Elimination event from a creature spawner.

The problem does not happen if the objective/creature was hit using a rocket launcher, and it also doesn’t happen if a Sleep (0.0) is inserted before the call to PutInStasis(). As far as I can tell, the pattern is that the call fails if it happens on a frame in which the player’s gun was fired.

Note this is nothing to do with an old issue that people have to do with needing to add a Sleep(0.0) in OnBegin. In this case we are not calling PutInStasis on the first frame, we are only doing it after receiving a damage message.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

1: create an empty project
2: add an objective device to the scene
3: add an item placer and set the item to an assault rifle
4: create a new verse device called stasis_test_device and paste the following code into it:

using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

stasis_test_device := class(creative_device):

@editable Objective : objective_device = objective_device{}

OnBegin<override>()<suspends>:void=
    Objective.GetHealth() # workaround DamageEvent bug
    StasisArgs := stasis_args{AllowTurning:=true, AllowFalling:=true, AllowEmotes:=false}

    loop:
        Result := Objective.DamagedEvent().Await()
        if(FortChar := Result.Instigator?.GetInstigatorAgent[].GetFortCharacter[]):
            Print("Put in stasis")
            #Sleep(0.0)
            FortChar.PutInStasis(StasisArgs)
            Sleep(5.0)
            Print("Release from stasis")
            FortChar.ReleaseFromStasis()

5: Compile Verse and drag an instance of the new device into the scene
6: assign the editable Objective variable to reference the objective device in the scene
7: launch the map
8: pick up the assault rifle and shoot at the objective device

Expected Result

I would expect to see the output “Put in stasis” and for the player to be locked in stasis for 5 seconds.

Observed Result

The output “Put in stasis” appears but the player is not locked. However if you enable the Sleep(0.0) on line 18 (by removing the #) and try again, now you will find it works and the player does get locked in stasis.

Platform(s)

Windows PC