1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【UEFN】Creature/Wildlife Spawner の Agent を Entity に変換し、NPC Component で操作できるか検証してみた

Posted at

はじめに

Creature Spwner Device からスポーンした Agent、
Wildlife Spawner Device からスポーンした Agent、

fort_character に変換できるのか?
変換できるなら Entity も取れるのだろうか?
Entity が取れたら、まさか NPCのComponentで操作できたりするのだろうか?

そういった気持ちから、どんな Component を持つのか調べてみました

Component をチェック✅ - Creature Spwner Device

スクリーンショット 2025-12-07 180632.png

検証結果

  • Agent を fort_character に変換し、 Entity を取得できました
  • この Entity は、NPCの Component を持っていません

ログ

========== PrintNPCComponents ==========
NPCEntities Count: 1
NPCEntities[0] 
 - Comps[0]:replication_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Deimos_Ranged_C_2147482643.replication_component_2147482645
 - Comps[1]:transform_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Deimos_Ranged_C_2147482643.transform_component_2147482645
 - Comps[2]:Characters_fort_character_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Deimos_Ranged_C_2147482643.Characters_fort_character_component_2147482634
 - Comps[3]:mass_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Deimos_Ranged_C_2147482643.mass_component_2147482634
===============================================
検証用コード・設定

検証用コード

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

creature_npc_test_device := class(creative_device):

    @editable
    Volume:volume_device = volume_device{}

    OnBegin<override>()<suspends>:void=
        for(Player : GetPlayspace().GetPlayers()):
            if(FC := Player.GetFortCharacter[]):
                FC.CrouchedEvent().Subscribe(OnCrouched)

    OnCrouched(CrouchedResult:tuple(fort_character, logic)):void=
        # プレイヤーがCrouch(しゃがみ)したときに処理を実行
        if:
            CrouchedResult(1)?
            Agent := CrouchedResult(0).GetAgent[]
        then:
            PrintNPCComponents()

    # ボリューム内のNPCが持っているコンポーネントをログ出力
    PrintNPCComponents():void=
        Print("========== PrintNPCComponents ==========")
        NPCEntities := GetNPCEntitiesWithFortCharacter()
        Print("NPCEntities Count: {NPCEntities.Length}")
        for(I -> NPCEntity : NPCEntities):
            Print("NPCEntities[{I}] ")
            for(J -> NPCComp : NPCEntity.GetComponents()):
                Print(" - Comps[{J}]:" + ToDiagnostic(NPCComp))
        Print("===============================================")

    # VolumeDevice 内にいる NPC の Entity を取得
    # - fort_character.GetEntity[] を使う方法
    GetNPCEntitiesWithFortCharacter():[]entity=
        var ReturnValue:[]entity = array{}
        for(I -> AgentInVolume : Volume.GetAgentsInVolume()):
            if:
                not player[AgentInVolume]
                NPCFC := AgentInVolume.GetFortCharacter[]
            then:
                if(NPCEntity := NPCFC.GetEntity[]):
                    set ReturnValue += array{NPCEntity}
        ReturnValue

プレイヤーがしゃがむと Volume Device 内にいる FortCharacter から、 Entity を取得します。 そして、 Entity のもつ Component を出力する処理をしています。

スクリーンショット 2025-12-07 180550.png

Volume Device 内に Creature Spawner Device を配置し、ゲーム開始後に1体をスポーンする設定です。

Component チェック✅ - Wildlife Spawner Device

検証結果

  • Agent を fort_character に変換し、 Entity を取得できました
  • この Entity は、 NPC の Component を... 持っていそうです
    「wildelife_actions_component」 は初めてみますし、公式情報はないですが、 guard_actions_component が npc_actions_component のサブクラスのように、 こちらも同じなのかもと思ったりしています

スクリーンショット 2025-12-07 183008 - コピー.png

ログ

LogVerse: : ========== PrintNPCComponents ==========
LogVerse: : NPCEntities Count: 1
LogVerse: : NPCEntities[0] 
LogVerse: :  - Comps[0]:transform_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Irwin_Grandma_Prefab_Entity_C_2147482645.transform_component_0
LogVerse: :  - Comps[1]:Animation_PlayAnimation_fort_npc_play_animation_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Irwin_Grandma_Prefab_Entity_C_2147482645.Animation_PlayAnimation_fort_npc_play_animation_component_0
LogVerse: :  - Comps[2]:AI_fort_wildlife_actions_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Irwin_Grandma_Prefab_Entity_C_2147482645.AI_fort_wildlife_actions_component_0
LogVerse: :  - Comps[3]:AI_fort_npc_perception_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Irwin_Grandma_Prefab_Entity_C_2147482645.AI_fort_npc_perception_component_0
LogVerse: :  - Comps[4]:AI_fort_npc_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Irwin_Grandma_Prefab_Entity_C_2147482645.AI_fort_npc_component_0
LogVerse: :  - Comps[5]:replication_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Irwin_Grandma_Prefab_Entity_C_2147482645.replication_component_0
LogVerse: :  - Comps[6]:Characters_fort_character_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Irwin_Grandma_Prefab_Entity_C_2147482645.Characters_fort_character_component_2147482630
LogVerse: :  - Comps[7]:mass_component /VKEdit/Maps/VKEdit_EmptyOcean_VolumeSupport.VKEdit_EmptyOcean_VolumeSupport:PersistentLevel.VKEdit_EmptyOcean_VolumeSupport_SimulationEntityActor.SimulationEntity.RoundLifetimeSimulationEntity.Irwin_Grandma_Prefab_Entity_C_2147482645.mass_component_2147482630
LogVerse: : ===============================================
検証用コード・設定

コードは Creature Spawner Device のものと同じで、デバイスだけ Wildlife Spawner に変更しています。

image.png

Volume Device 内に Wildlife Spawner Device を配置し、ゲーム開始後に1体をスポーンする設定です。

Wildlife Spawner Device の Agent を操作できるか?

スクリーンショット 2025-12-07 185305.png

検証結果

  • npc_actions_component.NavigateTo() を実行できました
検証用コード・設定
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /Verse.org/SceneGraph }
using { /Fortnite.com/AI }

creature_npc_test_device := class(creative_device):

    @editable
    Volume:volume_device = volume_device{}

    OnBegin<override>()<suspends>:void=
        for(Player : GetPlayspace().GetPlayers()):
            if(FC := Player.GetFortCharacter[]):
                FC.CrouchedEvent().Subscribe(OnCrouched)

    OnCrouched(CrouchedResult:tuple(fort_character, logic)):void=
        # プレイヤーがCrouch(しゃがみ)したときに処理を実行
        if:
            CrouchedResult(1)?
            Agent := CrouchedResult(0).GetAgent[]
        then:
            spawn:
                WildlifeNavigateTo_Test(Agent)

    # プレイヤーに向かって NPCを移動させる
    WildlifeNavigateTo_Test(Agent:agent)<suspends>:void=
        Print("========== WildlifeNavigateTo_Test ==========")
        if(SimE := GetSimulationEntity[]):
            NPCActionsComps := 
                for(Comp : SimE.FindDescendantComponents(npc_actions_component)){Comp}

            for(NPCActionsComp : NPCActionsComps):
                spawn:
                    NPCActionsComp.NavigateTo(MakeNavigationTarget(Agent))
        Print("===============================================")

スクリーンショット 2025-12-07 184625.png

Wildlife Spawner Device を配置し、広範囲に 30体スポーンする設定です。
この検証では、 GetSimulationEntity[] ゲーム内の npc_actions_component をもつ全ての Entity を対象にしているため、 Volume Device を使っていません。

ゲーム内の全ての野生生物(オオカミ)が、プレイヤーに向かって移動します

おわりに

Creature Spawner Device, Wildelife Spawner Deivce のどちらも、スポーンした Agent を Entity に変換できることがわかりました。
また、現時点で公式情報はないかと思いますが、Wildelife Spawner Device からスポーンした Agent は、 NPC の Component をもち、 Component で操作できるということも発見でした。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?