SetPresentableToPlayers' verse function not working

Summary

The SetPresentableToPlayers’ function in the verse digest is’nt working for hidding and showing entities to players.

Please select what you are reporting on:

Creative

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

Using the SetPresentableToPlayer with an empty array or an array with players on an entity will keep the entity visible to all players in the fort_playspace.

Here is a verse code i used on multiples entities with different components ( mesh_component , particle_system_component , light_component etc… ) :

using { /Verse.org }
using { /Verse.org/Native }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /Fortnite.com/Playspaces }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/ControlInput }
using {/Fortnite.com/Input/Character}
using { /Fortnite.com/Devices }
using { /Verse.org/Colors }

using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/SceneGraph/KeyframedMovement }

TestDebug := class<final_super>(component):

@editable Trigger : trigger_device = trigger_device {}

OnSimulate<override>()<suspends>:void=

    Trigger.TriggeredEvent.Subscribe(HandleToggleVisibility)

HandleToggleVisibility ( MaybeAgent : ?agent) : void =
    if ( P:=player[MaybeAgent?]):
        ToggleVisibility(P)

ToggleVisibility(P : player) : void =

    if ( Playspace := Entity.GetPlayspaceForEntity[]):

        var Found : logic = false
        MaybeArray:=Entity.GetPresentableToPlayers()

        if (Array:=MaybeArray?):

            for ( Player : Array , Player = P) :            #Cherche le joueur
                set Found = true

            if (Found?):
                Print ("The entity will be hidden for the player" , ?Color:=NamedColors.Red)

                if (NewPresentableArray:=Array.RemoveElement[Array.Find[P]]):
                    Entity.SetPresentableToPlayers(option {NewPresentableArray})

                else:
                    Err ("Can't find the player")

            else:
                Print("The entity will be Shown for the player" , ?Color:=NamedColors.Blue)
                Entity.SetPresentableToPlayers( option { Array + array {P} } )              

        else:
            var NewPresentableArray : []player = array {}
            for ( Player : Playspace.GetPlayers() , Player <> P):
                set NewPresentableArray += array {Player}
            Entity.SetPresentableToPlayers( option { NewPresentableArray } )
            Print ("The entity will be hidden for the player" , ?Color:=NamedColors.Red)
            return

    else:
        Print ("Error, could'nt find the playspace" , ?Color:=NamedColors.Red)

Expected Result

The entity should be swapping between visible and invisible to the player triggering the trigger_device.

Observed Result

The entity stay visible to all the players in the fort_playspace despite triggering the trigger_device named “Trigger” int the “TestDebug” component

Platform(s)

PC Windows

Thank’s to TrickTyger, I have become aware that this only works for entity prefabs that were spawned in. It does not work for entity prefabs that you placed. I have tested this and confirmed that it works this way.

1 Like

FORT-1087309 has been ‘Closed’. This is working as intended by design.

Oh really, sorry for the ticket and thank you a lot for your answer !

why would it be by design to limit it to only spawned entities? Doesn’t make any sense