ACharacter 的相机组件在哪里?
Where is the camera component located for ACharacter?
所以我刚开始玩Unreal Engine 4.我想尽可能多地学习,所以我从一个空白的C++项目开始。
我为我的玩家角色创建了一个新角色 class,然后基于此 class 创建了一个蓝图。
角色蓝图(或其某些组件似乎附加了一个 UCameraComponent,因为在制作了移动和外观的键绑定后 up/turn 我已经可以使用我的鼠标来导航相机了。
我的问题是,这个 UCameraComponent 位于哪里?当我打开蓝图时,似乎里面没有 CameraComponent。我也在ACharacter的源码里找过,也没找到。
我想调整与角色相关的相机位置,因为现在这个相机就在我的角色网格中。
您必须手动将其添加到您的 class。
在YourCharacter.h中:
UPROPERTY(EditAnywhere, Category = "Components")
USpringArmComponent* SpringArm = nullptr;
UPROPERTY(EditAnywhere, Category = "Components")
UCameraComponent* Camera = nullptr;
在YourCharacter.cpp构造函数中:
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
SpringArm->SetupAttachment(RootComponent);
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(SpringArm);
所以我刚开始玩Unreal Engine 4.我想尽可能多地学习,所以我从一个空白的C++项目开始。
我为我的玩家角色创建了一个新角色 class,然后基于此 class 创建了一个蓝图。
角色蓝图(或其某些组件似乎附加了一个 UCameraComponent,因为在制作了移动和外观的键绑定后 up/turn 我已经可以使用我的鼠标来导航相机了。
我的问题是,这个 UCameraComponent 位于哪里?当我打开蓝图时,似乎里面没有 CameraComponent。我也在ACharacter的源码里找过,也没找到。
我想调整与角色相关的相机位置,因为现在这个相机就在我的角色网格中。
您必须手动将其添加到您的 class。
在YourCharacter.h中:
UPROPERTY(EditAnywhere, Category = "Components")
USpringArmComponent* SpringArm = nullptr;
UPROPERTY(EditAnywhere, Category = "Components")
UCameraComponent* Camera = nullptr;
在YourCharacter.cpp构造函数中:
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
SpringArm->SetupAttachment(RootComponent);
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(SpringArm);