상호작용 컴포넌트(Interactable components)는 UEFN에서 기본적인 플레이어 상호작용을 간편하게 구현할 수 있도록 마련된 씬 그래프 컴포넌트(Scene Graph components)입니다.
이 컴포넌트를 사용하면 에이전트가 컴포넌트가 어태치된 엔티티와 상호작용할 수 있습니다.
상호작용(Interaction)은 에이전트가 상호작용을 시작하고, 상호작용 성공 시 신호를 받는 과정으로 정의됩니다. 예를 들어 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.
예시
첫 번째 예시에서는 사용자는 상태를 활성화에서 비활성화로 수정하는 메시와 상호작용할 수 있습니다. 엔티티는 컴퓨터의 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"
두 번째 예시에서는 상호작용이 등불 조명이 켜지도록 트리거합니다. 엔티티는 램프 메시 컴포넌트와 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_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