accidentally fixed the bug for camera component not being properly placed in-game; will need to fine tune the numbers next

This commit is contained in:
Ji Yoon Rhee
2024-01-04 23:03:39 +09:00
parent 586a7cf134
commit 191cd0dbdd
110 changed files with 21562 additions and 3135 deletions

View File

@ -6,6 +6,9 @@
#include "GameFramework/Actor.h"
#include "HYInteractableActor.generated.h"
/*
* Parent class for all interactable actor objects
*/
UCLASS()
class HWANYOUNG2_API AHYInteractableActor : public AActor
{
@ -15,9 +18,10 @@ public:
// Sets default values for this actor's properties
AHYInteractableActor();
//this is a Blueprint
//this is a Blueprint-only Event; does not have C++ implementation
UFUNCTION(BlueprintNativeEvent)
void Interact(APlayerController* Controller);
virtual void Interact_Implementation(APlayerController* Controller);
UPROPERTY(EditDefaultsOnly)

View File

@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HYWeapon.h"
// Sets default values
AHYWeapon::AHYWeapon()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AHYWeapon::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AHYWeapon::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}

View File

@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "HYWeapon.generated.h"
UCLASS()
class HWANYOUNG2_API AHYWeapon : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AHYWeapon();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};

View File

@ -43,45 +43,15 @@ float Ahwanyoung2Character::GetMaxGaugeP() const
Ahwanyoung2Character::Ahwanyoung2Character()
{
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate
// Note: For faster iteration times these variables, and many more, can be tweaked in the Character Blueprint
// instead of recompiling to adjust them
GetCharacterMovement()->JumpZVelocity = 700.f;
GetCharacterMovement()->AirControl = 0.35f;
GetCharacterMovement()->MaxWalkSpeed = 500.f;
GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
// Create a follow camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
Initialize();
}
Ahwanyoung2Character::Ahwanyoung2Character(const FObjectInitializer& ObjectInitializer):
Super(ObjectInitializer.SetDefaultSubobjectClass<UCharacterMovementComponent>(
ACharacter::CharacterMovementComponentName))
{
Initialize();
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
@ -261,6 +231,43 @@ void Ahwanyoung2Character::Look(const FInputActionValue& Value)
}
}
void Ahwanyoung2Character::Initialize()
{
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate
// Note: For faster iteration times these variables, and many more, can be tweaked in the Character Blueprint
// instead of recompiling to adjust them
GetCharacterMovement()->JumpZVelocity = 700.f;
GetCharacterMovement()->AirControl = 0.35f;
GetCharacterMovement()->MaxWalkSpeed = 500.f;
GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
// Create a follow camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
}
bool Ahwanyoung2Character::IsAlive() const
{
return GetHealth() > 0.0f;

View File

@ -32,7 +32,7 @@ class Ahwanyoung2Character : public ACharacter, public IAbilitySystemInterface
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USphereComponent* CollectionSphere;
#pragma region Controller
#pragma region Character Gameplay Input Action
/** MappingContext */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputMappingContext* DefaultMappingContext;
@ -49,9 +49,11 @@ class Ahwanyoung2Character : public ACharacter, public IAbilitySystemInterface
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* LookAction;
#pragma endregion move this to PlayerCharacController.h
#pragma endregion
private:
//Helper function for
void Initialize();
public:
UPROPERTY(BlueprintAssignable, Category = "Hwanyoung|Character")
@ -139,12 +141,6 @@ protected:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "HY_Character|Camera")
float BaseLookUpRate = 45.0f;
/*UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "HY_Character|Camera")
class USpringArmComponent* CameraBoom;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "HY_Character|Camera")
class UCameraComponent* FollowCamera;*/
//gameplaytags represent the states of the object;
//so if we were to modify the gameplay tags of a character,
//we are, comprehensively speaking, changing the states of
@ -182,14 +178,12 @@ protected:
/** Called for movement input */
void Move(const FInputActionValue& Value);
/** Called for looking input */
void Look(const FInputActionValue& Value);
/** Called for checking for the closest Interactable in sight and in range*/
void CheckForInteractables();
protected:
// APawn interface