fix: correct player character check
add player attribute component test class
This commit is contained in:
parent
d95a23f2e7
commit
40e5a37d91
|
|
@ -0,0 +1,34 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Characters/Components/ExoPlayerAttributesComponent.h"
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UExoPlayerAttributesComponent::UExoPlayerAttributesComponent()
|
||||
{
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts
|
||||
void UExoPlayerAttributesComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// ...
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
void UExoPlayerAttributesComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
#include "Player/ExoPlayerController.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "Characters/ExoPlayerCharacter.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
|
||||
|
|
@ -17,6 +18,9 @@ void AExoPlayerController::BeginPlay()
|
|||
Super::BeginPlay();
|
||||
check(InputContext);
|
||||
|
||||
PlayerCharacter = Cast<AExoPlayerCharacter>(GetPawn<ACharacter>());
|
||||
check(PlayerCharacter);
|
||||
|
||||
UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer());
|
||||
|
||||
if (Subsystem)
|
||||
|
|
@ -24,8 +28,6 @@ void AExoPlayerController::BeginPlay()
|
|||
Subsystem->AddMappingContext(InputContext, 0);
|
||||
}
|
||||
|
||||
PlayerCharacter = GetPawn<ACharacter>();
|
||||
|
||||
InteractionComponent = PlayerCharacter->FindComponentByClass<UInteractionComponent>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "ExoPlayerAttributesComponent.generated.h"
|
||||
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class EXO_API UExoPlayerAttributesComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UExoPlayerAttributesComponent();
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
#include <Player/InteractionComponent.h>
|
||||
#include "ExoPlayerController.generated.h"
|
||||
|
||||
class AExoPlayerCharacter;
|
||||
class UInputMappingContext;
|
||||
class UInputAction;
|
||||
struct FInputActionValue;
|
||||
|
|
@ -120,7 +121,7 @@ protected:
|
|||
TObjectPtr<UInputAction> ChangeWeaponAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
|
||||
TObjectPtr<ACharacter> PlayerCharacter;
|
||||
TObjectPtr<AExoPlayerCharacter> PlayerCharacter;
|
||||
|
||||
private:
|
||||
UInteractionComponent* InteractionComponent;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user