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
wiki:ue4:tips:500 [stepism@UE4メモ]

ユーザ用ツール

サイト用ツール


wiki:ue4:tips:500

以前のリビジョンの文書です —-


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

アクターの移動(4.7.5)

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

ブループリントで対応する

  1. 「コンテンツブラウザ」の「新規追加」から「Blueprints クラス」を選択する。
  2. 親クラスに「Actor」を選択して名前を「MyActor」にリネーム。
  3. MyActorをダブルクリックで編集画面を開く。

ブループリントエディター。EventGraphタブを開いておく。

ブループリントの編集

変数を追加する。

処理を追加する。

「Add Actor World Offset」 で相対的に座標移動出来る。
Vector型は右クリックから「構造体ピンを分割」してxyz各種パラメータにアクセスできる。
UE4 ブループリントで構造体の値を楽に渡す方法 - Let's Enjoy Unreal Engine



C++で対応する

  1. 「コンテンツブラウザ」の「新規追加」から「新規C++ Class…」を選択する。
  2. 親クラスに「Actor」を選択して次へ。
  3. 名前を「MyActor」として「クラスを作成」する。

コードの記述とコンパイル

  1. クラスが生成されると自動でVisual Studioが開くので、MyActor.h/cppを編集します。

変数を追加する。

 
class STDPROJECT_API AMyActor : public AActor 
{ 
    GENERATED_BODY() 
private: 
    // 追加 
    float RunningTime; 
} 

処理を追加する。

 

// コンストラクタ 
AMyActor::AMyActor() 
{ 
	PrimaryActorTick.bCanEverTick = true; 
	 
	RunningTime = 0.0f; 

	// ダミーのルートコンポーネント作成 
	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent")); 
} 

// 毎フレーム呼ばれる 
void AMyActor::Tick( float DeltaTime ) 
{ 
	Super::Tick( DeltaTime ); 

	float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime)); 

	// 相対的に移動させる 
	AddActorWorldOffset( FVector( 0, 0, DeltaHeight * 20.0f )); 

	RunningTime += DeltaTime; 
} 

プロジェクトをビルドしてエラーが出ないことを確認します。

Actorを配置する

  1. UE4エディターに戻って「コンテンツブラウザ」から「MyActor」をビューポートにドラッグ&ドロップする。
  2. 「ワールドアウトライナー」に「MyActor1」が追加されアクターの詳細が設定できる様になります。
  3. 「MyActor1」の「詳細パネル」の「コンポーネントを追加」から適当な図形を選択します。ここでは球(Sphere)を選択。

これでビューポートにアクターが表示されました。
実行すると上下にSin移動します。

wiki/ue4/tips/500.1429848102.txt.gz · 最終更新: 2016/03/06 10:32 (外部編集)