一.
1.相机不基于 Controller 旋转,角色自身也不 基于 Controller 进行旋转。
CameraBoom->SetupAttachment(MyRoot);
Camera->SetupAttachment(CameraBoom);
CameraBoom->TargetArmLength = 300;
CameraBoom->bDoCollisionTest = false;
Camera->bUsePawnControlRotation = false;
// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
2.让相机臂 可以 使用 基于Controller的旋转。
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
3.区别一个知识
.bOrientRotationToMovement
官方解释:
If true, rotate the Character toward the direction of acceleration, using RotationRate as the rate of rotation change.
改为false后人物不会自动向移动方向旋。
需牢记 若使用 二者 则bUseControllerRotationYaw 与 bOrientRotationToMovement 布尔值要相反 作者:是蛋黄蛋 https://www.bilibili.com/read/cv19334054/ 出处:bilibili
二.绑定输入输出,旋转
// Called to bind functionality to input
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
InputComponent->BindAxis("MouseWheel",this,&AMyPawn::Zoom);
//MouseXY
InputComponent->BindAxis("MouseX", this, &AMyPawn::RotateX);
InputComponent->BindAxis("MouseY", this, &AMyPawn::RotateY);
}
void AMyPawn::RotateX(float value)
{
if (value != 0)
{
AddControllerYawInput(value);
}
}
void AMyPawn::RotateY(float value)
{
if (value != 0)
{
AddControllerPitchInput(value);
}
}
三.在蓝图里也可以直观感受到。
Pawn设置,Pawn就不会跟着弹簧臂转。勾哪一个轴就跟着,那个轴就更着转。
CameraSpringArm
Camera这个true,false好像不影响,在子节点绑定到Arm上,但最好就false吧。