之前试着按照教程添加一个玩家蓝图类(继承c++pawn类),然后c++设置摄像机和摄像机臂,蓝图中调整位置,但是实际显示摄像机位置会有偏差,部分c++代码如下
// Sets default values
ASCharacter::ASCharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
SpringArmComp = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArmComp"));
SpringArmComp->bUsePawnControlRotation = true;
SpringArmComp->SetupAttachment(RootComponent);
CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComp"));
CameraComp->SetupAttachment(SpringArmComp);
}
正常显示如下
解决方法,先将摄像机和摄像机臂代码完成后再根据继承c++类建立蓝图类,拖入场景中可解决,这应该是UE4自带的bug。