가장 수월한 장애물 중 일부는 단순히 왕복으로만 이동합니다. 이러한 장애물은 타이밍에 맞춰 점프하고 추락을 피하기 위해 조심히 이동해야 하는 플랫폼 도전에서 종종 마주하게 됩니다.
이러한 방식으로 플랫폼을 움직이는 것, 즉 오브젝트 트랜스폼의 위치를 변경하는 것을 이동(translation)이라고 합니다. 이 섹션에서는 왕복으로 이동할 뿐만 아니라 월드의 여러 지점으로 이동할 수 있는 플랫폼을 만드는 방법을 알아본 다음, 이러한 플랫폼을 사용하여 첫 번째 장애물을 제작해 봅니다.
이동하는 사물 만들기
플랫폼을 이동하는 코드를 빌드하려면 아래 단계를 따릅니다.
Verse 익스플로러를 사용하여
movable_prop에서 상속되는 새 Verse 클래스animating_prop을 생성합니다. 이 클래스에<concrete>지정자를 추가하여 UEFN에 프로퍼티를 노출합니다.Verse# A prop that moves (translates) toward either a Creative prop target # or a position in world space. translating_prop<public> := class<concrete>(movable_prop):using { /Fortnite.com/Devices/CreativeAnimation }및using { /UnrealEngine.com/Temporary/SpatialMath }명령문을 파일 상단에 추가하여 해당 모듈을 임포트합니다. 이는 사물에 애니메이션을 적용하는 데 필요합니다. 이 섹션에서 사용된 툴팁도 여기에 포함됩니다.Verseusing { /Fortnite.com/Devices } using { /Fortnite.com/Devices/CreativeAnimation } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/SpatialMath } MovePositionTip<localizes>:message = "The optional position to move to World Space. Use this if you do not want to set a MoveTarget." # A prop that moves (translates) toward either a Creative prop target # or a position in world space. translating_prop<public> := class<concrete>(movable_prop):translating_prop클래스 정의 상단에 다음 필드를 추가합니다.MoveTargets로 명명된creative_prop의 편집 가능한 배열을 추가합니다.RootProp이 게임플레이 중에 이동할 포크리 사물입니다. 트랜스폼이 아닌 다른 사물을 이동 타깃으로 사용하면 사물이 어디로 향하는지 보다 손쉽게 시각화할 수 있습니다. 이는 나중에 에디터에서 게임플레이 중 표시되지 않도록 설정합니다.Verse# The Creative prop targets for the RootProp to move toward. @editable {ToolTip := MoveTargetsTip} var MoveTargets:[]creative_prop = array{}MovePosition으로 명명된 편집 가능한 선택사항vector3변수입니다.MoveTarget사물을 할당하지 않는 경우, 루트 사물은 이 변수를 사용하여 어디로 이동할지 파악합니다.Verse# The position for the RootProp to move toward. Use this if you # do not want to set a MoveTarget. @editable {ToolTip := MovePositionTip} var MovePosition:?vector3 = falseTargetPosition으로 명명된 변수vector3입니다. 이는 사물이 실제로 이동하는 위치로, 이동 타깃의 위치 또는MovePosition으로 설정됩니다.Verse# The position the prop is currently targeting. var TargetPosition:vector3 = vector3{}클래스 정의는 다음과 같습니다.
Verse# A prop that moves (translates) toward either a Creative prop target # or a position in world space. translating_prop<public> := class<concrete>(movable_prop): # The Creative prop targets for the RootProp to move toward. @editable {ToolTip := MoveTargetsTip} var MoveTargets:[]creative_prop = array{} # The optional position for the RootProp to move toward. Use this if you # do not want to set a MoveTarget.
이미
movable_prop에서 사물을 이동하는Move()함수를 구성했으므로 이 클래스에서 오버라이드할 수 있습니다.animating_prop클래스에서Move()함수를 오버라이드합니다.Verse# Translate toward the MovePosition, or MoveTarget if one is set. Move<override>()<suspends>:void=Move()의if표현식에서MovePosition이 설정되고 값NewPosition에 저장되었는지 확인합니다. 그러한 경우TargetPosition을NewPosition으로 설정합니다.Verse# Translate the RootProp toward the MoveTarget, or MovePosition if one is set. Move<override>()<suspends>:void= # Set the TargetPosition to the MovePosition if it is set. if: NewPosition := MovePosition? then: set TargetPosition = NewPositionMoveToEase()함수에는 이 함수로 전달할animation_mode가 필요합니다. 애니메이션은Move()가 호출될 때마다 한 번 재생되며,animation_mode는 애니메이션이 종료될 때 일어나는 일을 제어합니다.MoveToEase()를 호출해TargetPosition,MoveDuration,MoveEaseType및animation_mode.OneShot을 전달합니다. 이 애니메이션 모드를 사용하면 오브젝트가 타깃에 도달했을 때 애니메이션이 중지됩니다. 이는 앞서 구성한 오버로드된MoveToEase()함수로, 회전 또는 스케일을 받지 않습니다.Verse# Set the TargetPosition to the MovePosition if it is set. if: NewPosition := MovePosition? then: set TargetPosition = NewPosition # Call MoveToEase to start moving the prop. The OneShot animation mode will play the animation once. RootProp.MoveToEase(TargetPosition, MoveDuration, MoveEaseType, animation_mode.OneShot)오브젝트를 리셋하거나 계속 이동하도록 하려는 경우 원샷 애니메이션 모드가 유용하기는 하지만, 역으로 재생하려면 어떻게 해야 할까요? 이 경우
PingPong애니메이션 모드를 사용할 수 있습니다. 이 모드는 애니메이션을 재생한 다음 역재생하여 사물을 시작 위치로 되돌립니다. 애니메이션을 루프하는Loop애니메이션 모드도 있지만, 이 모드는 애니메이션이 시작된 위치에서 종료되어야 합니다. 경험의 필요에 맞는 적절한 애니메이션 모드를 선택하세요.사물을 구성할 때 에디터에서
MovePosition을 설정하지 않은 경우, 루트 사물이 이동할 하나 이상의MoveTargets를 설정해야 합니다.for표현식에서MoveTargets를 처리하려면MoveTargets의 각 타깃을 반복작업합니다.IsValid[]를 호출하여MoveTarget이 설정되어 있는지 확인합니다. 설정된 경우TargetPosition을MoveTarget의 이동으로 설정합니다.Verse# Set the TargetPosition to the MovePosition if it is set. if: NewPosition := MovePosition? then: set TargetPosition = NewPosition else: for: MoveTarget:MoveTargets do: # Set the TargetPosition to the MoveTarget's position if the마지막으로, 애니메이션 모드를 다시
animation_mode.OneShot으로 설정한 상태로MoveToEase()를 호출합니다.for표현식에서 이 작업을 수행하면 사물을 각 타깃으로 순서대로 이동하여 설정한 파라미터에 따라 종료 시 리셋하거나 계속합니다. 완성된Move()함수는 다음과 같습니다.Verse# Translate the RootProp toward the MoveTarget, or MovePosition if one is set. Move<override>()<suspends>:void= # Set the TargetPosition to the MovePosition if it is set. if: NewPosition := MovePosition? then: set TargetPosition = NewPosition # Call MoveToEase to start moving the prop. The OneShot animation mode will play the animation once.
Verse 장치 만들기
이제 Verse 코드가 완성되었으니 레벨 내에서 호출할 방법이 필요합니다. 또 하나의 Verse 장치를 사용하여 게임 시작 시 사물을 조정하고 모든 사물을 구성해 봅니다. 장애물을 조정하여 플랫폼을 이동하려면 다음 단계를 따릅니다.
Verse 익스플로러를 사용하여 새 Verse 장치
prop_animator를 생성합니다. 이는 사물 이동을 조정하는 장치입니다.prop_animator에서TranslatingProps로 명명한translating_prop의 편집 가능한 배열을 추가합니다. 그런 다음OnBegin()의for표현식에서 각 사물의Setup()을 호출합니다. 완성된prop_animator파일은 다음과 같습니다.Verseusing { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } TranslatingPropsTip<localizes>:message = "The props that translate (move) using animation." # Coordinates moving props through animation by calling each moveable_prop's Setup() method. prop_animator := class(creative_device): # Array of moveable_props that translate using animation.코드를 저장하고 컴파일합니다.
prop_animator장치를 레벨로 드래그합니다.
장치에 사물 연결하기
에디터로 돌아가 시작 부근에서 일부 사물을 삭제하여 틈새를 만듭니다. 레벨에 두 개의 FG01 Hover Platform M 사물을 추가합니다. 이 사물들이 애니메이션을 적용할 플랫폼이므로 TranslatingPlatform으로 명명합니다. 그런 다음 각 플랫폼이 이동할 타깃이 될 FG01 Button Bulb 사물을 몇 개 추가합니다. PlatformTarget으로 명명합니다. 틈새 위로 플랫폼을 배치하고, 플랫폼이 이동하도록 할 타깃을 배치합니다. 각 플랫폼에 여러 타깃을 지정할 수 있습니다.
이동 사물이 구성된 모습입니다. 각 플랫폼은 화살표로 표시된 대로 두 이동 타깃 사이에서 왕복 이동합니다.
게임플레이 중 타깃 사물을 숨기고 싶다면 각 타깃의 렌더링(Rendering)에서 액터 게임에서 숨김(Actor Hidden In Game)을 True로 설정합니다.
prop_animator 장치를 레벨로 드래그하고 선택합니다. 아웃라이너에서 배열 엘리먼트를 각 플랫폼의 TranslatingProps에 추가합니다. 각 사물에 다음 값을 할당합니다.
| 옵션 | 값 | 설명 |
|---|---|---|
MoveTargets | 사물이 이동할 타깃에 할당합니다. | 사물이 순차적으로 이동할 포크리 사물 타깃입니다. |
RootProp | 애니메이션을 적용할 사물에 할당합니다. | 애니메이션을 적용할 사물입니다. |
세션 시작(Launch Session)을 클릭하여 플랫폼 애니메이션을 확인합니다. MoveDuration, MoveEaseType, 시작 및 종료 딜레이를 다르게 설정하여 다양한 시나리오를 만들어 보세요.
이동 부분을 마쳤으니, 다음 섹션에서는 여러 방향으로 회전하는 사물을 만들어 보겠습니다.
다음 순서
완성된 코드
이 섹션에서 빌드한 완성된 코드는 다음과 같습니다.
translating_prop.verse
using { /Fortnite.com/Devices }
using { /Fortnite.com/Devices/CreativeAnimation }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
MovePositionTip<localizes>:message = "The optional position to move to World Space. Use this if you do not want to set a MoveTarget."
# A prop that moves (translates) toward either a Creative prop target
# or a position in world space.
translating_prop<public> := class<concrete>(movable_prop):
prop_animator.verse
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
TranslatingPropsTip<localizes>:message = "The props that translate (move) using animation."
# Coordinates moving props through animation by calling each moveable_prop's Setup() method.
prop_animator := class(creative_device):
# Array of moveable_props that translate using animation.