Warning: Declaration of action_plugin_linebreak::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php on line 41

Warning: Declaration of action_plugin_markdownextra::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/markdownextra/action.php on line 16

Warning: Declaration of action_plugin_syntaxhighlighter3_action::register(Doku_Event_Handler &$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/syntaxhighlighter3/action/action.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php:0) in /home/stepism/www/ue4/wiki/inc/auth.php on line 430

Warning: Cannot modify header information - headers already sent by (output started at /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php:0) in /home/stepism/www/ue4/wiki/inc/actions.php on line 38

Warning: Cannot modify header information - headers already sent by (output started at /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php:0) in /home/stepism/www/ue4/wiki/lib/tpl/dokuwiki/main.php on line 12
006 アクター(球)を配置して動かす(4.10) [stepism@UE4メモ]

ユーザ用ツール

サイト用ツール


wiki:tips:006

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

次のリビジョン
前のリビジョン
wiki:tips:006 [2016/03/06 07:36]
step 作成
wiki:tips:006 [2016/08/20 15:51] (現在)
step
ライン 1: ライン 1:
-====== 006 シンプルなActor(球)を配置して動かす(4.10) ======+====== 006 アクター(球)を配置して動かす(4.10) ======
  
 +===== 概要 =====
 +アクター(球)を配置して上下に動かしてみます。
 +----
 +
 +
 +コンテンツブラウザから新規追加→ブループリントクラスを選択し「親クラスを選択」から「アクター」を選択します。
 +{{:​wiki:​tips:​2016030621.png|}}
 +\\
 +\\
 +「アクター」はUnityで例えるならGameObjectの様なもので配置するもの全ての規定クラスと考えておいて良いです。
 +追加したアクター名は分かりやすい様に「SphereBP」に変更しておきます。
 +{{:​wiki:​tips:​2016030622.png|}}
 +
 +この「SphereBP」をダブルクリックすると「ブループリントエディター」が開きます。
 +
 +
 +----
 +
 +
 +
 +===== モデルの追加 =====
 +コンポーネントタブのコンポーネントを追加から「球」を追加します。
 +{{:​wiki:​tips:​20160306001.png|}}
 +
 +
 +----
 +
 +===== ブループリントの記述 =====
 +
 +[[https://​docs.unrealengine.com/​latest/​JPN/​Programming/​QuickStart/​index.html|Unreal Engine | プログラマ向けクイックスタート]]
 +を参考にして上下に移動する球を実装してみます。
 +
 +「イベントグラフ」タブを選択してノードを書いていくことで、「SphereBP」の動きを実装します。
 +{{:​wiki:​tips:​2016030623.png|}}
 +
 +
 +=== 変数の追加 ===
 +「マイブループリント」タブの「変数」にRunningTime 変数を追加します。
 +時間経過で上下に動かしたいので型はfloatにしておきます。
 +
 +{{:​wiki:​tips:​2016030624.png|}}
 +
 +変数左側の、ここでは緑色アイコンを右クリックすると変数を配列に切り替えることができます。
 +
 +----
 +
 +=== 実装 ===
 +
 +Event Tick ノードから処理を開始します。Event Tickはマイフレーム呼ばれるノードになっています。
 +まずはActorを動かすらめのノードEvent Tickから呼び出します。
 +{{:​wiki:​tips:​2016030625.png|}}
 +
 +AddActorWorldTransform ノードを追加しました。
 +これは現在のTransform(姿勢)を相対的に変化させる時に使用するノードです。
 +さらにAddActorWorldTransform から「Set RunningTime」としてノードを追加します。
 +{{:​wiki:​tips:​2016030626.png|}}
 +
 +ここで、ノードの色が3色あることに気づきます。
 +
 +^色^意味^
 +|赤|処理の開始|
 +|青|関数|
 +|緑|変数|
 +
 +例では「**EventTick** から始まり、**AddActorWorldTransform** でアクターを動かし、**RunningTime**に時間を設定する」という流れになっています。
 +
 +=== コンパイルエラーが出ている ===
 +
 +さて、このままではAddActorWorldTransformに引数が何も渡されていない状態なためコンパイルエラーが出てしまうので、新しいノードを追加します。
 +
 +何もないところを右クリックして「Add Math Expression」を検索し選択します。
 +{{:​wiki:​tips:​2016030627.png|}}
 +
 +「Add Math Expression」ノードは数式を扱えるノードです。
 +C++などに馴染んでいる人は、式がそのままかけるためとても便利です。
 +
 +{{:​wiki:​tips:​2016030628.png|}}
 +
 +図の様に上下にSin運動させるための式を記述します。
 +
 +<code cpp>
 +Sin(RunningTime)
 +</​code>​
 +
 +計算式はできたので、計算結果をAddActorWorldTransformの引数として渡したい所ですが、
 +float型のパラメータを渡す箇所が見当たりません。
 +
 +
 +そんな場合はAddActorWorldTransformのTranformを右クリックし「構造体ピンを分割(Split Struct Pin)」します。
 +{{:​wiki:​tips:​2016030629.png|}}
 +
 +同じ要領で分割されたピンをさらに分割することも可能なので、今回の場合分割されたVector型をさらに分割します。
 +そして、分割されたピンに先ほどの計算結果を渡します。
 +
 +{{:​wiki:​tips:​2016030630.png|}}
 +
 +これで渡せました。
 +
 +あとは、RunningTimeを更新するための式を書いて、ピンを繋げてあげて完成です。
 +<code cpp>
 +(RunningTime + DeltaSeconds)
 +</​code>​
 +
 +{{:​wiki:​tips:​2016030631.png|}}
 +
 +==== 完成したブループリント ====
 +
 +{{:​wiki:​tips:​2016030632.png|}}
 +
 +完成したらコンパイルボタンを押します。どこか不備があればエラーが表示されます。
 +{{:​wiki:​tips:​2016030633.png|}}
 +
 +----
 +
 +==== レベルに配置する ====
 +ブループリントエディタを閉じレベルエディタに戻って「SphereBP」をレベルにドラック&ドロップで追加します。
 +{{:​wiki:​tips:​2016030634.png|}}
 +
 +
 +適度に確認しやすい位置に調整します。
 +{{:​wiki:​tips:​2016030635.png|}}
 +
 +「プレイ」ボタンで再生します。
 +{{:​wiki:​tips:​2016030636.png|}}
 +
 +これで上下にSin移動するアクターができました。
  
wiki/tips/006.1457249783.txt.gz · 最終更新: 2016/03/06 07:36 by step