c++ - UE4 - 使用 CameraComponent 时观众不旋转(俯仰)

标签 c++ camera rotation multiplayer unreal-engine4

我的观众没有收到来自被跟随球员的任何投球轮换。


我正尝试与 ShooterGame 项目合作,对 FPS 旁观者功能进行概念验证。 我在 GameMode 中添加了将 VictimPlayer 切换到旁观者模式的代码:

VictimPlayerState->bIsSpectator = true;
PlayerController->ChangeState(NAME_Spectating);
PlayerController->ClientGotoState(NAME_Spectating);

我还向 PlayerController 添加了逻辑,它将观众的 View 切换到下一个玩家:

void AShooterPlayerController::BeginSpectatingState()
{
    Super::BeginSpectatingState();

    ServerViewNextPlayer();
}

而且它工作得很好。 但如果我将 CameraComponent 添加到 ShooterCharacter - 我的观众不会收到任何俯仰旋转。

AShooterCharacter::AShooterCharacter(const FObjectInitializer& ObjectInitializer)
    : Super(ObjectInitializer.SetDefaultSubobjectClass<UShooterCharacterMovement>(ACharacter::CharacterMovementComponentName))
{

    FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
    FirstPersonCameraComponent->SetupAttachment(GetCapsuleComponent());
    FirstPersonCameraComponent->RelativeLocation = FVector(-39.56f, 1.75f, 64.f); // Position the camera
    FirstPersonCameraComponent->bUsePawnControlRotation = true;

    Mesh1P = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("PawnMesh1P"));
    Mesh1P->SetupAttachment(FirstPersonCameraComponent);
    GetMesh()->SetupAttachment(FirstPersonCameraComponent);
...

我在这里错过了什么?我相信 CameraComponent 是更改默认相机位置的标准方法,因此旁观者机制应该支持这一点。 如果有任何帮助,我将不胜感激。

最佳答案

事实证明,Pawn 上的“Use Controller Rotation Pitch”必须设置为 true(Yaw 默认为 true)。 问题已解决。

关于c++ - UE4 - 使用 CameraComponent 时观众不旋转(俯仰),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57250208/

相关文章:

3d - 使用透视相机矩阵将 3D 点投影到 2D 屏幕空间

android - 将内容 URI 与 ACTION_VIDEO_CAPTURE 结合使用

matrix - 从二维变换矩阵中获取旋转

matlab - 旋转矩阵按列计算而不是按行计算

c++ - Boost 测试在使用 Clang 4.1 (LLVM 3.1svn) 退出时崩溃

c++ - 创建给定最小值、最大值和长度的曲线

C++:隐藏子类中的成员。是否有意义?

c++ - 如何在 OSX(或跨平台)c++ 上实现没有 GLU 的 FPS 相机

ios - Swift:在二维中旋转点

java - 在 C++ 中使用 java 类时找不到类