Space Plunder
Loading...
Searching...
No Matches
AQuestExampleCharacter Class Reference

#include <QuestExampleCharacter.h>

Inheritance diagram for AQuestExampleCharacter:
ACharacterBase ICharacterBaseInterface ISaveLoad IBaseInterface

Public Member Functions

 AQuestExampleCharacter (const FObjectInitializer &ObjectInitializer)
 
FORCEINLINE class USpringArmComponent * GetCameraBoom () const
 
FORCEINLINE class UCameraComponent * GetFollowCamera () const
 
virtual void SetupPlayerInputComponent (class UInputComponent *PlayerInputComponent) override
 
- Public Member Functions inherited from ACharacterBase
 ACharacterBase (const FObjectInitializer &ObjectInitializer)
 
virtual void Tick (float DeltaTime) override
 
virtual bool SaveGame () override
 
virtual bool LoadGame () override
 
virtual USkeletalMeshComponent * GetCharacterMesh () const override
 
virtual UPrimitiveComponent * GetPrimitiveComponent () override
 
virtual void Ragdoll () override
 
virtual void RagdollStop () override
 
virtual float PlayReplicatedMontage (UAnimMontage *MontageToPlay, const float InPlayRate=1.0f, const EMontagePlayReturnType ReturnValueType=EMontagePlayReturnType::Duration, const float InTimeToStartMontageAt=0.0f, const bool bStopAllMontages=true) override
 
virtual void StopReplicatedMontage (const float InBlendOutTime, const UAnimMontage *Montage) override
 
virtual bool GetCharacterHealth (float &Health, float &MaxHealth) const override
 
virtual FCharacterBaseSkillsGetCharacterSkills () override
 
virtual bool GetAudioSocketLocation (const FName &AudioSocket, FVector &Location) const override
 
virtual USceneComponent * GetThrowPoint () const override
 
virtual FCharacterInfo GetCharacterInfo () const override
 
virtual void GetThrowStats (FTransform &OutTransform, FVector &OutThrowForce) const override
 
virtual void CharacterModeChanged (const FGameplayTag &NewMode) override
 
virtual int32 GetStrength () const
 
virtual int32 GetPerception () const
 
virtual int32 GetEndurance () const
 
virtual int32 GetCharisma () const
 
virtual int32 GetIntelligence () const
 
virtual int32 GetAgility () const
 
virtual int32 GetWeaponSkill () const
 
virtual int32 GetStealth () const
 
virtual int32 GetLuck () const
 
virtual int32 GetSkillPoints () const
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void OnPawnSpawned () override
 
void Move (const FInputActionValue &Value)
 
void Look (const FInputActionValue &Value)
 
- Protected Member Functions inherited from ACharacterBase
virtual void NotifyHit (UPrimitiveComponent *MyComp, AActor *Other, UPrimitiveComponent *OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult &Hit) override
 
virtual void FallOver (const float WaitTime)
 
void OnFallOver (const float WaitTime)
 
virtual void GetUpFromFall ()
 
void OnGetUpFromFall ()
 
void OnRep_CharacterDeath ()
 
IPlayerControllerInterfaceGetPlayerControllerInterface ()
 
IPlayerStateInterfaceGetPlayerStateInterface ()
 
void LogDebugError (const FString &Message) const
 
void LogDebugError (const FString &Message, const int32 Value) const
 
void LogDebugError (const FString &Message, const float Value) const
 
void LogDebugWarning (const FString &Message) const
 
void LogDebugWarning (const FString &Message, const int32 Value) const
 
void LogDebugWarning (const FString &Message, const float Value) const
 
void LogDebugMessage (const FString &Message, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const int32 Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const float Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const bool bValue, const bool bWarning, const bool bError) const
 
void LogOnScreenMessage (const int32 Key, const FString &Message, FColor Color=FColor::Green) const
 
void SetCategoryName (const FLogCategoryBase &Category)
 

Protected Attributes

class USpringArmComponent * CameraBoom
 
class UCameraComponent * FollowCamera
 
class UInputMappingContext * DefaultMappingContext
 
class UInputAction * JumpAction
 
class UInputAction * MoveAction
 
class UInputAction * LookAction
 
- Protected Attributes inherited from ACharacterBase
bool bDebuggingMode = false
 
FCharacterBaseSkills CharacterSkills
 
FCharacterInfo CharacterInfo
 
bool bDead = false
 
float PickupThrowIntensity = 500.0f
 
bool bCanBePushed = false
 
float HitVelocityThreshold = 50.0f
 
float HitVelocityMultiplier = 5.0f
 
float HitReactionMultiplier = 0.01f
 
bool bPushHitReaction = true
 
bool bAddMovementInput = true
 
bool bAddCharacterMovement = true
 
float PushFallVelocityThreshold = 200.0f
 
float PushedFallVelocityThreshold = 500.0f
 
float PushedFallOverWaitTime = 2.0f
 

Additional Inherited Members

- Public Attributes inherited from ACharacterBase
FOnCharacterDeath OnCharacterDeath
 

Constructor & Destructor Documentation

◆ AQuestExampleCharacter()

AQuestExampleCharacter::AQuestExampleCharacter ( const FObjectInitializer & ObjectInitializer)
explicit
16 : Super(ObjectInitializer)
17{
18 // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
19 PrimaryActorTick.bCanEverTick = true;
20 // Set size for collision capsule
21 GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
22
23 // Don't rotate when the controller rotates. Let that just affect the camera.
24 bUseControllerRotationPitch = false;
25 bUseControllerRotationYaw = false;
26 bUseControllerRotationRoll = false;
27
28 // Configure character movement
29 GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
30 GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate
31
32 // Note: For faster iteration times these variables, and many more, can be tweaked in the Character Blueprint
33 // instead of recompiling to adjust them
34 GetCharacterMovement()->JumpZVelocity = 700.f;
35 GetCharacterMovement()->AirControl = 0.35f;
36 GetCharacterMovement()->MaxWalkSpeed = 500.f;
37 GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
38 GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;
39
40 // Create a camera boom (pulls in towards the player if there is a collision)
41 CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
42 CameraBoom->SetupAttachment(RootComponent);
43 CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character
44 CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
45
46 // Create a follow camera
47 FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
48 FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
49 FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
50
51 // Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
52 // are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
53
54}
class USpringArmComponent * CameraBoom
Definition QuestExampleCharacter.h:40
class UCameraComponent * FollowCamera
Definition QuestExampleCharacter.h:44

Member Function Documentation

◆ BeginPlay()

void AQuestExampleCharacter::BeginPlay ( )
overrideprotectedvirtual

Reimplemented from ACharacterBase.

58{
59 Super::BeginPlay();
60 //Add Input Mapping Context
61 if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
62 {
63 if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
64 {
65 Subsystem->AddMappingContext(DefaultMappingContext, 0);
66 }
67 }
68}
class UInputMappingContext * DefaultMappingContext
Definition QuestExampleCharacter.h:49

◆ GetCameraBoom()

FORCEINLINE class USpringArmComponent * AQuestExampleCharacter::GetCameraBoom ( ) const
inline

Returns CameraBoom subobject

21{ return CameraBoom; }

◆ GetFollowCamera()

FORCEINLINE class UCameraComponent * AQuestExampleCharacter::GetFollowCamera ( ) const
inline

Returns FollowCamera subobject

23{ return FollowCamera; }

◆ Look()

void AQuestExampleCharacter::Look ( const FInputActionValue & Value)
protected

Called for looking input

127{
128 // input is a Vector2D
129 FVector2D LookAxisVector = Value.Get<FVector2D>();
130
131 if (Controller != nullptr)
132 {
133 // add yaw and pitch input to controller
134 AddControllerYawInput(LookAxisVector.X);
135 AddControllerPitchInput(LookAxisVector.Y);
136 }
137}

◆ Move()

void AQuestExampleCharacter::Move ( const FInputActionValue & Value)
protected

Called for movement input

104{
105 // input is a Vector2D
106 FVector2D MovementVector = Value.Get<FVector2D>();
107
108 if (Controller != nullptr)
109 {
110 // find out which way is forward
111 const FRotator Rotation = Controller->GetControlRotation();
112 const FRotator YawRotation(0, Rotation.Yaw, 0);
113
114 // get forward vector
115 const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
116
117 // get right vector
118 const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
119
120 // add movement
121 AddMovementInput(ForwardDirection, MovementVector.Y);
122 AddMovementInput(RightDirection, MovementVector.X);
123 }
124}

◆ OnPawnSpawned()

void AQuestExampleCharacter::OnPawnSpawned ( )
overrideprotectedvirtual

Reimplemented from ACharacterBase.

71{
72 Super::OnPawnSpawned();
73 //Add Input Mapping Context
74 if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
75 {
76 if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
77 {
78 Subsystem->AddMappingContext(DefaultMappingContext, 0);
79 }
80 }
81}

◆ SetupPlayerInputComponent()

void AQuestExampleCharacter::SetupPlayerInputComponent ( class UInputComponent * PlayerInputComponent)
overridevirtual

Reimplemented from ACharacterBase.

85{
86 Super::SetupPlayerInputComponent(PlayerInputComponent);
87 // Set up action bindings
88 if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) {
89
90 //Jumping
91 EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::Jump);
92 EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
93
94 //Moving
95 EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AQuestExampleCharacter::Move);
96
97 //Looking
98 EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AQuestExampleCharacter::Look);
99
100 }
101}
void Look(const FInputActionValue &Value)
Definition QuestExampleCharacter.cpp:126
void Move(const FInputActionValue &Value)
Definition QuestExampleCharacter.cpp:103
class UInputAction * LookAction
Definition QuestExampleCharacter.h:61
class UInputAction * MoveAction
Definition QuestExampleCharacter.h:57
class UInputAction * JumpAction
Definition QuestExampleCharacter.h:53

Member Data Documentation

◆ CameraBoom

class USpringArmComponent* AQuestExampleCharacter::CameraBoom
protected

Camera boom positioning the camera behind the character

◆ DefaultMappingContext

class UInputMappingContext* AQuestExampleCharacter::DefaultMappingContext
protected

MappingContext

◆ FollowCamera

class UCameraComponent* AQuestExampleCharacter::FollowCamera
protected

Follow camera

◆ JumpAction

class UInputAction* AQuestExampleCharacter::JumpAction
protected

Jump Input Action

◆ LookAction

class UInputAction* AQuestExampleCharacter::LookAction
protected

Look Input Action

◆ MoveAction

class UInputAction* AQuestExampleCharacter::MoveAction
protected

Move Input Action


The documentation for this class was generated from the following files: