以前のリビジョンの文書です
—-
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
Warning: Declaration of syntax_plugin_markdownextra::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/markdownextra/syntax.php on line
38
Warning: Declaration of syntax_plugin_markdownextra::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/markdownextra/syntax.php on line
47
Warning: Declaration of syntax_plugin_syntaxhighlighter3_syntax::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/syntaxhighlighter3/syntax/syntax.php on line
53
Warning: Declaration of syntax_plugin_syntaxhighlighter3_syntax::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/syntaxhighlighter3/syntax/syntax.php on line
82
006 シンプルなActor(球)を配置して動かす(4.10)
コンテンツブラウザから新規追加→ブループリントクラスを選択し「親クラスを選択」から「アクター」を選択します。
「アクター」はUnityで例えるならGameObjectの様なもので配置するもの全ての規定クラスと考えておいて良いです。
追加したアクター名は分かりやすい様に「SphereBP」に変更しておきます。
この「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を右クリックし「構造体ピンを分割」します。
同じ要領で分割されたピンをさらに分割することも可能なので、今回の場合分割されたVector型をさらに分割します。
そして、分割されたピンに先ほどの計算結果を渡します。
これで渡せました。
あとは、RunningTimeを更新するための式を書いて、ピンを繋げてあげて完成です。
(RunningTime + DeltaSeconds)
完成したブループリント
完成したらコンパイルボタンを押します。どこか不備があればエラーが表示されます。
レベルの配置する
ブループリントエディタを閉じレベルエディタに戻って「SphereBP」をレベルにドラック&ドロップで追加します。
適度に確認しやすい位置に調整します。
「プレイ」ボタンで再生します。