fix: 玩家第一人称摄像机

This commit is contained in:
2025-12-06 20:35:54 +08:00
parent 83e7924776
commit 445e60f1d1
5 changed files with 11 additions and 18 deletions

View File

@@ -13,4 +13,9 @@
/** /**
* @defgroup UI 用户界面系统 * @defgroup UI 用户界面系统
* 包含所有用户界面相关类。 * 包含所有用户界面相关类。
*/ */
/**
* @defgroup UnitTest 单元测试
* 包含所有自动化单元测试类。
* /

View File

@@ -32,17 +32,9 @@ ASurviverPlayer::ASurviverPlayer() {
// Set size for collision capsule // Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f); GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f);
// Create the first person mesh that will be viewed only by this character's owner
// CharacterMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("角色 Mesh"));
// CharacterMesh->SetupAttachment(GetMesh());
// CharacterMesh->SetOnlyOwnerSee(true);
// CharacterMesh->FirstPersonPrimitiveType = EFirstPersonPrimitiveType::FirstPerson;
// CharacterMesh->SetCollisionProfileName(FName("NoCollision"));
// Create the Camera Component // Create the Camera Component
CharacterCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("First Person Camera")); CharacterCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("First Person Camera"));
// CharacterCameraComponent->SetupAttachment(CharacterMesh, FName("head")); CharacterCameraComponent->SetupAttachment(this->GetMesh(), FName("head"));
// CharacterCameraComponent->SetupAttachment(this->GetMesh(), FName("head"));
CharacterCameraComponent-> CharacterCameraComponent->
SetRelativeLocationAndRotation(FVector(-2.8f, 5.89f, 0.0f), FRotator(0.0f, 90.0f, -90.0f)); SetRelativeLocationAndRotation(FVector(-2.8f, 5.89f, 0.0f), FRotator(0.0f, 90.0f, -90.0f));
CharacterCameraComponent->bUsePawnControlRotation = true; CharacterCameraComponent->bUsePawnControlRotation = true;

View File

@@ -22,10 +22,6 @@ UCLASS()
class FIRSTPERSONDEMO_API ASurviverPlayer : public ACharacter, public IDamageableInterface { class FIRSTPERSONDEMO_API ASurviverPlayer : public ACharacter, public IDamageableInterface {
GENERATED_BODY() GENERATED_BODY()
// /** Pawn mesh: first person view */
// UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true"))
// USkeletalMeshComponent* CharacterMesh;
/** First person camera */ /** First person camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true")) UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true"))
UCameraComponent* CharacterCameraComponent; UCameraComponent* CharacterCameraComponent;