서의 공간

Pawn 본문

Unreal Engine

Pawn

홍서의 2021. 11. 9. 13:53

GetBaseAimRotation

/**
* Return the aim rotation for the Pawn.
* If we have a controller, by default we aim at the player's 'eyes' direction
* that is by default the Pawn rotation for AI, and camera (crosshair) rotation for human players.
*/
UFUNCTION(BlueprintCallable, Category=Pawn)
virtual FRotator GetBaseAimRotation() const;

FRotator APawn::GetBaseAimRotation() const
{
	// If we have a controller, by default we aim at the player's 'eyes' direction
	// that is by default Controller.Rotation for AI, and camera (crosshair) rotation for human players.
	FVector POVLoc;
	FRotator POVRot;
	if( Controller != nullptr && !InFreeCam() )
	{
		Controller->GetPlayerViewPoint(POVLoc, POVRot);
		return POVRot;
	}

	// If we have no controller, we simply use our rotation
	POVRot = GetActorRotation();

	// If our Pitch is 0, then use a replicated view pitch
	if( FMath::IsNearlyZero(POVRot.Pitch) )
	{
		if (BlendedReplayViewPitch != 0.0f)
		{
			// If we are in a replay and have a blended value for playback, use that
			POVRot.Pitch = BlendedReplayViewPitch;
		}
		else
		{
			// Else use the RemoteViewPitch
			POVRot.Pitch = RemoteViewPitch;
			POVRot.Pitch = POVRot.Pitch * 360.0f / 255.0f;
		}
	}

	return POVRot;
}
  1. Controller가 있고 FreeCam상태가 아니라면 Controller가 바라보는 rotator를 반환
  2. Controller가 없다면 폰의 rotation을 반환
  3. 만약 ROVRot.Pitch가 0에 근접하면(0과 같다면), ...

'Unreal Engine' 카테고리의 다른 글

컨트롤러 방향  (2) 2021.12.16
AIController에서 BehaviorTreeComponent  (2) 2021.12.12
Set Timer 사용법  (0) 2021.12.12
속도, MakeFromX, MakeRotFromX  (0) 2021.11.09
[UMG] Drag & Drop  (0) 2021.10.29
Comments