レベルを設定する
開始するには、Fall Guys Starter の島テンプレートから新規プロジェクトを作成して初期化します。 このスターター島には、ユーザーがナビゲートする事前作成済みコースが入っており、このチュートリアルではその移動をカスタマイズします。
動かす小道具を定義する
小道具の移動を開始する前に、どれが移動可能な小道具であるかを定義する必要があります。 Verse の仕掛けを使用して小道具を直接動かすこともできますが、複数の小道具を同時に動かす場合には処理しづらくなることがあります。 その代わりに、抽象 movable_prop クラスを定義します。 このクラスには、動かす小道具、および移動のロジックとタイミングをカスタマイズするために使用する他のいくつかの値が入っています。
以下の手順に従って、移動可能な小道具を定義します。
Verse Explorer を使用して、
movable_propという新規 Verse クラスを作成します。 これは Verse クラスであり、仕掛けではないため、このファイルを作成するには [Create Empty (空ファイルを作成)] を使用します。 このクラスは、さまざまなタイプの移動可能な小道具のサブクラスを派生させる抽象クラスであるため、このクラスに<abstract>指定子を付加します。 Verse で新規クラスを作成する方法については、「初めての Verse プログラムを変更して実行する」を参照してください。Verse# Defines a Creative prop that moves to a target or location using animation. movable_prop<public> := class<abstract>():using { /Fortnite.com/Devices }、using { /Verse.org/Simulation }、およびusing { /UnrealEngine.com/Temporary/SpatialMath }というインポート パスをファイルの先頭に追加します。 小道具を動かす数学演算を処理するために、これらのモジュールをインポートする必要があります。このクラスの各フィールドには、
ToolTipも含まれています。 編集可能フィールドにToolTipメッセージを追加すると、UEFN でそのフィールドをマウス オーバーしたときにツールチップが表示されます。 このクラスで使用されているすべてのツールチップを以下に示しています。 これらのツールチップをコピーすることも、独自のツールチップを定義することもできます。Verseusing { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/SpatialMath } MoveDurationTip<localizes>:message = "The amount of time the prop takes to move to its destination." MoveEaseTypeTip<localizes>:message = "The animation easing applied to the movement." MoveEndDelayTip<localizes>:message = "The delay after the movement finishes." MoveOnceAndStopTip<localizes>:message = "Whether the RootProp should stop in place after it finishes moving." MoveStartDelayTip<localizes>:message = "The delay before the movement starts." MoveTargetsTip<localizes>:message = "The array of CreativeProp to move toward. These targets can be children of the RootProp."移動可能な各小道具で必要とされるフィールドを定義します。
movable_propのクラス定義に以下のフィールドを追加します。RootPropという編集可能なcreative_prop。 これは、ゲームプレイ中にあちこち動かすクリエイティブの小道具です。Verse# The Creative prop associated with this class. # This should be the root prop of the object you want to move. @editable {ToolTip := RootPropTip} RootProp:creative_prop = creative_prop{}MoveDurationという編集可能なfloat値。 これは、小道具を目的地まで動かすのにかかる時間です。Verse# The duration in seconds it takes for the prop to move to its destination. @editable {ToolTip := MoveDurationTip} MoveDuration:float = 3.0MoveStartDelayという編集可能なfloat値。 これは、移動する前に小道具が待機する時間 (秒) です。Verse# The duration in seconds to wait before movement begins. @editable {ToolTip := MoveStartDelayTip} MoveStartDelay:float = 0.0MoveEndDelayという名前の編集可能なfloat値。 これは、移動した後に小道具が待機する時間 (秒) です。Verse# The duration in seconds to wait after movement ends. @editable {ToolTip := MoveEndDelayTip} MoveEndDelay:float = 0.0MoveOnceAndStopという名前の編集可能なlogic。 これは、小道具が 1 回だけ移動するか、移動を繰り返すかを制御します。Verse# Whether the RootProp should stop in place when it finishes moving. @editable {ToolTip := MoveOnceAndStopTip} MoveOnceAndStop:logic = falseShouldResetという名前の編集可能なlogic。 これは、移動が完了した後に、小道具を元の位置にリセットするかどうかを制御します。Verse# Whether the RootProp should reset back to the starting position when it # finishes moving. @editable {ToolTip := ShouldResetTip} ShouldReset:logic = falseStartingTransformという transform 変数。 これは、移動を開始するときのRootPropのトランスフォームです。Verse# The starting transform of the RootProp. var StartingTransform:transform = transform{}
最終的なクラス定義は次のようになります。
Verseusing { /Fortnite.com/Devices } using { /Fortnite.com/Devices/CreativeAnimation } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/SpatialMath } MoveDurationTip<localizes>:message = "The amount of time in seconds the prop takes to move to its destination." MoveEaseTypeTip<localizes>:message = "The animation easing applied to the movement." MoveEndDelayTip<localizes>:message = "The delay after the movement finishes." MoveOnceAndStopTip<localizes>:message = "Whether the RootProp should stop in place after it finishes moving." MoveStartDelayTip<localizes>:message = "The delay before the movement starts."小道具が移動する前に、どこから移動するかを知っておく必要があります。 そうするために、移動する前に
StartingTransformを設定する新しい関数を定義します。新しいメソッド
SetStartingTransform()をmovable_propクラス定義に追加します。SetStartingTransform()内で、GetTransform()を使用して、StartingTransformをRootPropのトランスフォームに設定します。完成した
SetStartingTransform()関数は次のようになります。Verse# Sets the StartingTransform to the current transform of the RootProp. SetStartingTransform():void= set StartingTransform = RootProp.GetTransform()
小道具の移動を開始するには、新しい関数
Move()を次のように定義します。新しいメソッド
Move()をmovable_propクラス定義に追加します。この関数が非同期で実行できるように、
<suspends>モディファイアを付加します。 これは、この関数の基本クラス バージョンであり、使用されないため、即座にreturnを呼び出すだけです。完成した
Move()関数は次のようになります。Verse# Move the RootProp to its target. This is the base class # version of this function and should not be used. Move()<suspends>:void= return
移動が完了したときに小道具をリセットする場合は、その開始位置にテレポートする必要があります。 そうするために、新しいメソッド
Reset()をmovable_propクラス定義に追加します。この関数がリセットの失敗時にロールバックできるように、この関数に
<decides><transacts>モディファイヤを付加します。 ロールバックは、ゲームプレイ中に小道具が破棄された場合に発生することがあります。Reset()内で、TeleportTo[]を使用して、RootPropをそのStartingTransformにテレポートします。完成した
Reset()関数は次のようになります。Verse# Reset the RootProp by teleporting it back to its Starting Transform. Reset()<decides><transacts>:void= RootProp.TeleportTo[StartingTransform]
次に、ここまでで定義した多くの関数をすべて結びつけます。 移動のさまざまな関数を管理するために、新しいメソッド
ManageMovement()をmovable_propクラス定義に追加します。 この関数が非同期で実行できるように、<suspends>モディファイアを付加します。Verse# Loops moving the RootProp to its target by calling Move(), and handles # any logic when the movement begins and ends. ManageMovement()<suspends>:void=ManageMovement()内で、移動を管理するloop式を作成します。 その loop 式内で、MoveStartDelay秒間Sleep()した後に、Move()を呼び出します。Verse# Loops moving the RootProp to its target by calling Move(), and handles # any logic when the movement begins and ends. ManageMovement()<suspends>:void= loop: Sleep(MoveStartDelay) Move()プラットフォームで移動が完了すると、移動を続行するか、位置をリセットするか、その場で停止する必要があります。 停止を処理するために、
if式で、MoveOnceAndStopが true であるかどうかをチェックします。 true であれば、breakでループを抜けます。 移動を停止した後に、MoveEndDelay秒間Sleep()します。 最後に、もう一つのif式で、ShouldResetが true であるかどうかをチェックし、true であれば、Reset[]を呼び出します。 完成したManageMovement()関数は次のようになります。Verse# Loops moving the RootProp to its target by calling Move(), and handles # any logic when the movement begins and ends. ManageMovement()<suspends>:void= loop: Sleep(MoveStartDelay) Move() # If the prop should only move once and stop, then exit the loop. if:このクラスには
OnBegin()関数がないため、他のクラスでManageMovement()を呼び出してプラットフォームの移動を開始する方法が必要です。 新しい関数Setup()をmovable_propクラス定義に追加します。Setup()内で、SetStartingTransform()を呼び出した後に、ManageMovement()関数をスポーンして、プラットフォームを動かします。 完成したSetup()関数は次のようになります。Verse# Set the StartingTransform, then begin movement by spawning ManageMovement. Setup():void= SetStartingTransform() spawn{ManageMovement()}
次の内容
抽象クラスが完成したので、次のステップでは、アニメーションを通して小道具を動かす方法について説明します。
完全なコード
このセクションで作成した完全なコードを以下に示します。
movable_prop.verse
using { /Fortnite.com/Devices }
using { /Fortnite.com/Devices/CreativeAnimation }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
MoveDurationTip<localizes>:message = "The amount of time in seconds the prop takes to move to its destination."
MoveEaseTypeTip<localizes>:message = "The animation easing applied to the movement."
MoveEndDelayTip<localizes>:message = "The delay after the movement finishes."
MoveOnceAndStopTip<localizes>:message = "Whether the RootProp should stop in place after it finishes moving."
MoveStartDelayTip<localizes>:message = "The delay before the movement starts."