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

Warning: Declaration of syntax_plugin_linebreak::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /home/stepism/www/ue4/wiki/lib/plugins/linebreak/syntax.php on line 52

Warning: Declaration of syntax_plugin_linebreak::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /home/stepism/www/ue4/wiki/lib/plugins/linebreak/syntax.php on line 74

006 アクター(球)を配置して動かす(4.10)

概要

アクター(球)を配置して上下に動かしてみます。
—-

コンテンツブラウザから新規追加→ブループリントクラスを選択し「親クラスを選択」から「アクター」を選択します。


「アクター」はUnityで例えるならGameObjectの様なもので配置するもの全ての規定クラスと考えておいて良いです。
追加したアクター名は分かりやすい様に「SphereBP」に変更しておきます。

この「SphereBP」をダブルクリックすると「ブループリントエディター」が開きます。


モデルの追加

コンポーネントタブのコンポーネントを追加から「球」を追加します。


ブループリントの記述

Unreal Engine | プログラマ向けクイックスタート を参考にして上下に移動する球を実装してみます。

「イベントグラフ」タブを選択してノードを書いていくことで、「SphereBP」の動きを実装します。

変数の追加

「マイブループリント」タブの「変数」にRunningTime 変数を追加します。
時間経過で上下に動かしたいので型はfloatにしておきます。

変数左側の、ここでは緑色アイコンを右クリックすると変数を配列に切り替えることができます。


実装

Event Tick ノードから処理を開始します。Event Tickはマイフレーム呼ばれるノードになっています。
まずはActorを動かすらめのノードEvent Tickから呼び出します。

AddActorWorldTransform ノードを追加しました。
これは現在のTransform(姿勢)を相対的に変化させる時に使用するノードです。
さらにAddActorWorldTransform から「Set RunningTime」としてノードを追加します。

ここで、ノードの色が3色あることに気づきます。

意味
処理の開始
関数
変数

例では「EventTick から始まり、AddActorWorldTransform でアクターを動かし、RunningTimeに時間を設定する」という流れになっています。

コンパイルエラーが出ている

さて、このままではAddActorWorldTransformに引数が何も渡されていない状態なためコンパイルエラーが出てしまうので、新しいノードを追加します。

何もないところを右クリックして「Add Math Expression」を検索し選択します。

「Add Math Expression」ノードは数式を扱えるノードです。
C++などに馴染んでいる人は、式がそのままかけるためとても便利です。

図の様に上下にSin運動させるための式を記述します。

Sin(RunningTime) 

計算式はできたので、計算結果をAddActorWorldTransformの引数として渡したい所ですが、
float型のパラメータを渡す箇所が見当たりません。

そんな場合はAddActorWorldTransformのTranformを右クリックし「構造体ピンを分割(Split Struct Pin)」します。

同じ要領で分割されたピンをさらに分割することも可能なので、今回の場合分割されたVector型をさらに分割します。
そして、分割されたピンに先ほどの計算結果を渡します。

これで渡せました。

あとは、RunningTimeを更新するための式を書いて、ピンを繋げてあげて完成です。

(RunningTime + DeltaSeconds) 

完成したブループリント

完成したらコンパイルボタンを押します。どこか不備があればエラーが表示されます。


レベルに配置する

ブループリントエディタを閉じレベルエディタに戻って「SphereBP」をレベルにドラック&ドロップで追加します。

適度に確認しやすい位置に調整します。

「プレイ」ボタンで再生します。

これで上下にSin移動するアクターができました。

wiki/tips/006.txt · 最終更新: 2016/08/20 15:51 by step