ボタンで姿を表示/非表示

要件

  1. ボタンの仕掛けを二つ設置する(A, B)
  2. ボタンAを押すとプレイヤーを表示する
  3. ボタンBを押すとプレイヤーが非表示になる

使用する仕掛け

  1. ボタンの仕掛け(x2)

使用する機能

確認する
# Sets this `fort_character` visibility to visible.
Show<public>():void

# Sets this `fort_character` visibility to invisible.
Hide<public>():void

回答

回答を見る
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters }

button_show_hide_device := class(creative_device):
    @editable
    ShowButtonDevice:button_device = button_device{}
    @editable
    HideButtonDevice:button_device = button_device{}

    OnBegin<override>()<suspends>:void=
        ShowButtonDevice.InteractedWithEvent.Subscribe(OnInteractShow)
        HideButtonDevice.InteractedWithEvent.Subscribe(OnInteractHide)

    OnInteractShow(Agent:agent):void=
        if(FortCharacter := Agent.GetFortCharacter[]):
            FortCharacter.Show()

    OnInteractHide(Agent:agent):void=
        if(FortCharacter := Agent.GetFortCharacter[]):
            FortCharacter.Hide()