Adding FixedPointCamera during Player Respawn Bug

Reference ID

5d3df63a-49f6-b9db-7900-f5b0b2b72e75

Please select what you are reporting on:

Creative

What Type of Bug are you experiencing?

Devices

Summary

There is an issue when that occurs whenever you try to add and remove a Fixed Point Camera Device to a player while they are respawning. It will only work the first time a player respawns, but the next time you try to add the Fixed Point Camera Device during the time the player respawns, the camera will not get added. Sometimes it doesn’t even work the first time you try to add the camera while they are respawning.

Steps to Reproduce

Step 1: Have a player subscribe to the EliminatedEvent. It should look something like this (FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)
Step 2: In this OnPlayerEliminated function that you bind to the EliminatedEvent for the character, attach a Fixed Point Camera Device to the player. It should look something like this (FixedPointCamera.AddTo(EliminatedAgent))
Step 3: Create a timer, call it something like RevertCameraTimer, and bind the SuccessEvent of the timer to a function that will remove the Camera from the player. It should look something like this (RevertCameraTimer.SuccessEvent.Subscribe(RevertCamera).
Step 4: In the RevertCamera function, there should be a call to remove the camera from the player. It should look something like this (FixedPointCamera.RemoveFrom(Agent))
Step 5: Kill the player, notice how the camera will change for them
Step 6: Kill the player again, notice how the camera doesn’t change

Expected Result

The Fixed Point Camera should become the player’s active camera

Observed Result

The Fixed Point Camera does not become the player’s active camera

Platform(s)

windows

Additional Notes

Here is some sample code that will help you replicate the bug:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /UnrealEngine.com/Temporary/Diagnostics }

test := class(creative_device):
    @editable
    TestCamera:gameplay_camera_fixed_point_device = gameplay_camera_fixed_point_device{}
    @editable
    TestTimer:timer_device = timer_device{}
    
    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        for (Player : GetPlayspace().GetPlayers()):
            if (FortChar := Player.GetFortCharacter[]):
                FortChar.EliminatedEvent().Subscribe(HandlePlayerEliminated)

        TestTimer.SuccessEvent.Subscribe(RevertCamera)
    
    HandlePlayerEliminated(Result : elimination_result):void=

        Eliminated := Result.EliminatedCharacter

        if (Agent := Eliminated.GetAgent[]):
            # Add the camera to the agent
            Print("Camera should be added")
            TestCamera.AddTo(Agent)

            # Trigger a timer that will change the camera back to normal
            TestTimer.Start(Agent)
    
    RevertCamera(Agent: ?agent):void=
        if (CurAgent := Agent?):
            TestCamera.RemoveFrom(CurAgent)