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
ターゲットに対してビルボード処理する(4.7.6) [stepism@UE4メモ]

ユーザ用ツール

サイト用ツール


wiki:ue4:tips:505

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_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

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


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

ターゲットに対してビルボード処理する(4.7.6)

FindLookAtRotation を使えばターゲットへの角度を取得出来るので、それを利用して常にプレイヤーの方向を向くビルボード処理を実装します。

ブループリント版

BillBoardComponentとしてコンポーネント化しておいて、実装して好きな時に着け外し出来る様にしています。まず、Actor型のTargetActor変数を追加して、そこにプレイヤーのアクターをセットしています。その後SetActorRotation してRotationを決定します。Rotationの値は「Find Look At Rotation」を使ってターゲットへのRotationを求めています。これでLookAt的な事が出来ます。毎フレーム実行することで常にプレイヤーの方向を向き続けるビルボードアクターが実装できます。


C++版

 
//  
// 毎フレーム更新されます。 
//  
void UBillboardActorComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) 
{ 
	Super::TickComponent( DeltaTime, TickType, ThisTickFunction ); 

	// プレイヤー(ターゲットのアクター)取得 
	AActor* targetActor = UGameplayStatics::GetPlayerPawn(GetWorld(), 0); 

	// 親アクター取得 
	AActor* ownerActor = Super::GetOwner(); 

	// 親アクターの向き決定 
	// FindLookAtRotationにアクセス出来ないので、同様の処理を実装します。 
	FVector Forward = (targetActor->GetActorLocation() - ownerActor->GetActorLocation()); 
	FRotator newRot = FRotationMatrix::MakeFromX(Forward).Rotator(); 

	// Rotation設定 
	ownerActor->SetActorRotation(newRot); 
} 

C++版には「FindLookAtRotation」が使えずリンクエラーになるのでMakeFromXで代用しました。

wiki/ue4/tips/505.1431499634.txt.gz · 最終更新: 2015/07/02 16:59 (外部編集)