インタラクト可能コンポーネントは、UEFN での基本的なプレーヤー インタラクションを簡素化するために設計された Scene Graph コンポーネントです。
これらのコンポーネントにより、エージェントはコンポーネントがアタッチされているエンティティを操作できるようになります。
インタラクションは、エージェントが開始を試み、インタラクションの成功を通知されること (PC で E キーを押すなど) によって定義されます。 コンポーネントは、インタラクションで実行する内容を指示するのではなく、インタラクションを行うエージェントとインタラクト可能なコンポーネント間のハンドシェイクのみを処理します。
interactable_component
interactable_component は、プレイヤーにゲーム内のオブジェクトを操作するアビリティを付与する基盤となります。
インタラクションは通常、プレイヤーがオブジェクトの横にあるインタラクション ボタンを押したときに発生します。 この基本コンポーネントにより、ゲーム イベントをトリガーするために必要な最小限のインタラクションが可能になります。
interactable_component が動作するには、mesh_component にアタッチする必要があります。
Verse を使用すると、コンポーネントのデフォルトの動作をオーバーライドして、カスタムのインタラクションを作成できます。 詳細については、「interactable_component クラスの API リファレンス」を参照してください。
Verseクラス
interactable_component クラスは、インタラクションを開始し、コンポーネントとそれをインタラクションする各エージェントの両方のクールダウンを管理できます。
# An interactable component allows an agent to start and succeed at an interaction.
# The functionality of what happens on success should be implemented by overriding the success event.
interactable_component<public> := class(component, enableable):
# Set the enable/disable for interaction of the component.
Enable<override>()<transacts> : void
Disable<override>()<transacts> : void
IsEnabled<override>()<decides><reads> : void
# Event fires when an interaction starts. Sends the interacting agent.
例
この最初の例では、ユーザーはメッシュを操作して状態を Enabled から Disabled に変更することができます。 エンティティは、コンピュータの mesh_component とカスタマイズされた interactable_enableable_component で構成されています。
以下は interactable_enableable_component で使用されるコードです。
using { /Verse.org }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /Fortnite.com/Game }
# Allows a Enable/Disable state on the interactable_component
interactable_enableable_component<public> := class<final_super>(interactable_component):
# Default text to show on the UI
EnabledText<localizes> : message = "Enabled"
この 2 番目の例では、インタラクションによってランタン内のライトが点灯します。 エンティティは、ランプ メッシュ コンポーネントと interactable_enableable_light_component で構成されています。
以下は interactable_enableable_light_component で使用されるコードです。
using { /Verse.org }
using { /Verse.org/Native }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
# Will turn on/off a light after interacting with the entity
interactable_enableable_light_component<public> := class<final_super>(interactable_enableable_component):
# Entity who has the light_component attached
@editable
basic_interactable_component
これは現在、実験的機能です。したがって、それらを試したり、フィードバックを提供したり、計画を確認したりできます。 実験段階でアセットを作成した場合、下位互換性は保証されません。これらの機能の API は変更される場合があります。実験的機能のすべて、または特定の機能を独自の裁量で削除する場合があります。 この機能を使用する前に、既知の問題の一覧を確認してください。
basic_interactable_component により、インタラクション パラメータをより細かく制御できるようになります。
basic interactable コンポーネントでは、インタラクションの成功までに経過する必要のある期間をインタラクションに設定することが可能です。このコンポーネントにより、複数のインタラクションを同時に許可することで、これに伴い生じる可能性のある複雑性に対処できます。
また、インタラクションするエージェントに応じて異なる、各インタラクション間のクールダウン時間を管理する方法も提供されます。
インタラクションは basic_interactable_component Verse クラスによって制御されます。
Verseクラス
# An interactable component with a composable feature set.
basic_interactable_component<public> := class(interactable_component):
# Cooldowns begin elapsing on successful interactions. A cooldown which applies for all attempts to interact on this component.
@editable
Cooldown<public> : ?interactable_cooldown = false
# Cooldowns begin elapsing on successful interactions. A cooldown which applies for future attempts to interact on this component by the agent which succeeded.
@editable
CooldownPerAgent<public> : ?interactable_cooldown_per_agent = false