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
ターゲットに対してビルボード処理する(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で代用しました。