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/Action/Export.php on line 103

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/Action/Export.php on line 103

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/Action/Export.php on line 103
====== ターゲットに対してビルボード処理する(4.7.6) ====== FindLookAtRotation を使えばターゲットへの角度を取得出来るので、それを利用して常にプレイヤーの方向を向くビルボード処理を実装します。 ===== ブループリント版 ===== {{:wiki:ue4:tips:ue4_billboardcomponent.png?300|}} 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で代用しました。