はじめに
Creature Spwner Device からスポーンした Agent、
Wildlife Spawner Device からスポーンした Agent、
fort_character に変換できるのか?
変換できるなら Entity も取れるのだろうか?
Entity が取れたら、まさか NPCのComponentで操作できたりするのだろうか?
そういった気持ちから、どんな Component を持つのか調べてみました
Component をチェック✅ - Creature Spwner Device
検証結果
- 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 を出力する処理をしています。
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 のサブクラスのように、 こちらも同じなのかもと思ったりしています
ログ
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 に変更しています。
Volume Device 内に Wildlife Spawner Device を配置し、ゲーム開始後に1体をスポーンする設定です。
Wildlife Spawner Device の Agent を操作できるか?
検証結果
- 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("===============================================")
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 で操作できるということも発見でした。





