UEソースコードを読むためのC++の勉強なので、パスを書いておく
UE_4.25\Engine\Source\Runtime\Engine\Public\DrawDebugHelpers.hの
DrawDebugCamera()を使うための
/** Draw a debug camera shape. FOV is full angle in degrees. */ENGINE_API void
/ **デバッグカメラの形状を描画します。 FOVは度単位の全角です。 * /エンジンのAPI
DrawDebugCamera(const UWorld* InWorld, FVector const& Location, FRotator const& Rotation, float FOVDeg, float Scale=1.f, FColor const& Color=FColor::White, bool bPersistentLines=false, float LifeTime=-1.f, uint8 DepthPriority = 0);
UE_4.25\Engine\Source\Runtime\Engine\Classes\GameFramework\Controller.hのGetPlayerViewPoint()
/**
* Returns Player’s Point of View
* For the AI this means the Pawn’s ‘Eyes’ ViewPoint
* For a Human player, this means the Camera’s ViewPoint
*
* @output out_Location, view location of player
* @output out_rotation, view rotation of player
*/
/ *
プレイヤーの視点を返します
AIの場合、これはポーンの「目」ビューポイントを意味します
人間のプレイヤーの場合、これはカメラのビューポイントを意味します
@output out_Location、プレーヤーの場所を表示
@output out_rotation、プレーヤーの回転を表示
*/
virtual void GetPlayerViewPoint( FVector& Location, FRotator& Rotation ) const;
Gun.cpp
#include "DrawDebugHelpers.h"
void AGun::PullTrigger()
{
UE_LOG(LogTemp,Warning,TEXT("You have been shot!! "));
//MuzzleFlashSocket
UGameplayStatics::SpawnEmitterAttached(MuzzleFlash, Mesh, TEXT("MuzzleFlashSocket"));
APawn* OwnerPawn = Cast<APawn>(GetOwner());
if(OwnerPawn==nullptr)
{
return;
}
AController* OwnerController= OwnerPawn ->GetController();
if(OwnerController==nullptr)
{
return;
}
FVector Location;
FRotator Rotation;
OwnerController->GetPlayerViewPoint( Location, Rotation );
//DrawDebugCamera(UWorld, Location, Rotation, float FOVDeg, float Scale=1.f, FColor const& Color=FColor::White, bool bPersistentLines=false, float LifeTime=-1.f, uint8 DepthPriority = 0);
float FOVDeg=90;
float Scale=2.f;
FColor const& Color=FColor::Blue;
bool bPersistentLines=true;
float LifeTime=-1.f;
uint8 DepthPriority = 0;
DrawDebugCamera(GetWorld(), Location, Rotation, FOVDeg, Scale, Color, bPersistentLines, LifeTime, DepthPriority);
}
