[Experimental - Scene Graph Cameras] Inconsistency in player’s camera_director behavior between Edit and Playtest Sessions

Summary

Adding a Scene Graph Camera to the player’s camera_director does not behave correctly in play sessions as opposed edit session.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Scene Graph

Steps to Reproduce

1 - Create a camera entity
2 - Create a device that checks if a player spawned device spawns a player
3 - attempt to add the camera to the players camera_director on spawn

Expected Result

Edit Sessions: Player correctly gets the camera added to their viewport

Play Sessions: Same as Edit Sessions

Observed Result

Edit Sessions: Player correctly gets the camera added to their viewport

Play Sessions: Player doesn’t get the camera added to their viewport.

Platform(s)

Windows

Hello there!

Just received this bug and am looking into it.

I’m not sure if the sample code on the bug was provided by you or our QA department, but if it was provided by you then I did find an issue in the sample code that I think could explain the issue you’re having.

if:
P := GetPlayspace().GetPlayers()[0]
FC := P.GetFortCharacter
PlayerEntity := FC.GetEntity
Cam := CameraEntity.GetComponent[physical_camera_component]
then:
... some code that attempts to find camera_director_component via PlayerEntity

The issue here is that this code is attempting to get the camera_director_component from the entity that represents the player’s character, not the player itself.

The entity that the camera_director_component lives on is the actual player entity (In this example that would be this entity here:

P := GetPlayspace().GetPlayers()[0]

When setting up the camera system in my test UEFN projects, I usually either hook into the events that get fired when a player joins, or use a trigger volume and cast the agent that entered the volume to a player, as those are easy ways to get access to a player entity.

Can you try getting the camera_director_component directly from a player entity and see if that solves your problem? If not I can investigate further.

If that works for you, then it sounds like we maybe need to update our documentation to make that a bit more clear.

Thank you!

2 Likes

Hi there, thanks for the response!

The code i’m currently experiencing the edit/play session discrepancy in is provided here, this code is ran after the player spawns, triggered by the spawn event in the player spawn pad.

I am directly applying my Camera Entity to the player’s Camera director, not the physical player entity.

I could provide a private island code if you need more information on reproducing.

        if:
            Player := player[Agent]
            Director := Player.GetCameraDirector[]
            FortChar := Agent.GetFortCharacter[]
            FortCharEntity := FortChar.GetEntity[]
            CameraEntity := E_PlayerCamera{}
            Camera := CameraEntity.GetComponent[camera_component]
        then:
            ApplyMovementPreset(CurrentMovementPreset)
            CameraEntity.AddComponents(array{Camera})
            Entity.AddEntities(array{CameraEntity})
            OrbitModifier :=
                fort_orbit_camera_modifier{
                    TargetEntity := Entity,

                    BoomArmOffsetCentimeters := vector3{
                        Left := 0.0,
                        Up := EyeHeight,
                        Forward := 0.0
                    },

                    CameraDistanceCentimeters := 0.0,
                    CameraHeightCentimeters := 0.0,
                    EnableCollision := false,
                    RotationOffset := IdentityRotation()
                }
            set CrouchCameraModifier = option{OrbitModifier}
            Camera.CameraModifiers.AddModifier(OrbitModifier,2)
            if:
                Director.AddCamera[Camera,100]
            then:
                Init(FortChar)
                Sleep(1.0)

Forgot to attach, helper function i use in this snippet is here.

    first:
        Director:Player.FindDescendantComponents(camera_director_component)
    do:
        Director```

I think this is a side effect of another issue:

In UE, we can select where the “listener” is in the world (We can say “this client will hear the audios as if he was on this position”)
But we don’t have anything like that in UEFN/Verse. So we can’t override the “listener position” to where we want (Ex. attached to some camera, attached to the pawn, or another actor).

There are different cases where we may want to hear sounds from different positions (such as around player even when using a far away/top-down camera or something), or if we want to hear sounds from the camera position, another programatic location manually set, or even more than one listener/locations at once…
Sadly we don’t have anything to configure this :frowning:

That’s odd… I haven’t hooked into the spawn event on the player spawn pad before. I wonder if it’s one of those events that triggers really early (as in during loading), and maybe it’s getting run before the camera_director_component has been added to the player?

Does it still happen if you put a large delay before attempting to access the camera director component?

(Obviously that’s not a proper fix, but if that’s what’s causing it, I can investigate if there’s a way to add the director earlier)

From what i’ve tested the actual if: check on the player’s camera director do technically pass, but we don’t get any observable change in the players camera state, even if i add a significant delay.

I was able to reproduce this locally using player_spawner_device, but for me the problem was that the player spawned before I could subscribe to the spawner event’s SpawnedEvent, so my event handler never got called. I was able to get around it by also iterating through all players at the time of subscription, and calling my InitCamera function for all players that had already spawned before I could hook up my callback. Once I did that, the camera behaved as expected.

It sounds like from what you’re saying that you’re getting a bit further than that, so if this doesn’t work for you, then feel free to send me a private island code and I’ll debug further.

Here’s a quick component I wrote to test this:
(Note: Don’t take this code to be best practice or anything like that, I just threw it together to see if I could repro this bug locally)

activate_on_spawn_component := class<final_super>(component):

    @editable
    SpawnerDevice : player_spawner_device = player_spawner_device{}

    @editable
    CameraEntity : entity = entity{}

    @editable
    EyeHeight : float = 64.0

    # Runs when the device is started in a running game
    OnSimulate<override>()<suspends>:void =
        Print("Spawner Subscribe")
        SpawnerDevice.SpawnedEvent.Subscribe(OnSpawned)

        Print("Activate for all players")
        # Initialize camera system for all existing players
        if:
            AllPlayers := Entity.GetPlayspaceForEntity[].GetPlayers()
        then:
            for (PlayerToInit : AllPlayers):
                InitCamera(PlayerToInit)

    OnSpawned(Agent:agent):void =
        spawn{InitCamera(Agent)}

    InitCamera(Agent:agent)<suspends>:void=
        Print("Init Camera for Player")
        if:
            Player := player[Agent]
            Director := Player.GetComponent[camera_director_component]
        then:
            Print("Got director")
        else:
            Print("No director")

        if:
            SimEntity := Entity.GetSimulationEntity[]
            Player := player[Agent]
            Director := Player.GetComponent[camera_director_component]
            FortChar := Agent.GetFortCharacter[]
            FortCharEntity := FortChar.GetEntity[]
            Camera := CameraEntity.GetComponent[camera_component]
        then:
            OrbitModifier :=
                fort_orbit_camera_modifier{
                    TargetEntity := FortCharEntity,

                    BoomArmOffsetCentimeters := vector3{
                        Left := 0.0,
                        Up := EyeHeight,
                        Forward := 0.0
                    },

                    CameraDistanceCentimeters := 0.0,
                    CameraHeightCentimeters := 0.0,
                    EnableCollision := false,
                    RotationOffset := IdentityRotation()
                }
            Camera.CameraModifiers.AddModifier(OrbitModifier,2)
            if:
                Director.AddCamera[Camera,100]
            then:
                Sleep(1.0)
1 Like

FORT-1152840 is ‘Closed’ as ‘Fixed’. The issue will be addressed in 43.00.