我的观众没有收到来自被跟随球员的任何投球轮换。
我正尝试与 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/