fix: initialize components in constructor to prevent crash
This commit is contained in:
parent
1b93280fa7
commit
c9a138e1ab
Binary file not shown.
|
|
@ -2,12 +2,19 @@
|
||||||
|
|
||||||
|
|
||||||
#include "Characters/ExoPlayerCharacter.h"
|
#include "Characters/ExoPlayerCharacter.h"
|
||||||
|
|
||||||
|
#include "Characters/Components/ShootingComponent.h"
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
|
#include "Player/InteractionComponent.h"
|
||||||
|
|
||||||
AExoPlayerCharacter::AExoPlayerCharacter()
|
AExoPlayerCharacter::AExoPlayerCharacter()
|
||||||
{
|
{
|
||||||
GetCharacterMovement()->bSnapToPlaneAtStart = true;
|
GetCharacterMovement()->bSnapToPlaneAtStart = true;
|
||||||
|
|
||||||
|
InteractionComponent = CreateDefaultSubobject<UInteractionComponent>(TEXT("Interaction Component"));
|
||||||
|
|
||||||
|
ShootingComponent = CreateDefaultSubobject<UShootingComponent>(TEXT("Shooting Component"));
|
||||||
|
|
||||||
bUseControllerRotationPitch = true;
|
bUseControllerRotationPitch = true;
|
||||||
bUseControllerRotationYaw = true;
|
bUseControllerRotationYaw = true;
|
||||||
bUseControllerRotationRoll = false;
|
bUseControllerRotationRoll = false;
|
||||||
|
|
@ -16,5 +23,5 @@ AExoPlayerCharacter::AExoPlayerCharacter()
|
||||||
void AExoPlayerCharacter::BeginPlay()
|
void AExoPlayerCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
check(InteractionComponent && ShootingComponent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ void AExoPlayerController::BeginPlay()
|
||||||
InteractionComponent = PlayerCharacter->FindComponentByClass<UInteractionComponent>();
|
InteractionComponent = PlayerCharacter->FindComponentByClass<UInteractionComponent>();
|
||||||
ShootingComponent = PlayerCharacter->FindComponentByClass<UShootingComponent>();
|
ShootingComponent = PlayerCharacter->FindComponentByClass<UShootingComponent>();
|
||||||
|
|
||||||
// Ustawianie w komponencie poruszania prędkości zapisanej w characterze
|
// Ustawianie w komponencie poruszania pr<EFBFBD>dko<EFBFBD>ci zapisanej w characterze
|
||||||
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
#include "Characters/ExoCharacterBase.h"
|
#include "Characters/ExoCharacterBase.h"
|
||||||
#include "ExoPlayerCharacter.generated.h"
|
#include "ExoPlayerCharacter.generated.h"
|
||||||
|
|
||||||
|
class UInteractionComponent;
|
||||||
|
class UShootingComponent;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class EXO_API AExoPlayerCharacter : public AExoCharacterBase
|
class EXO_API AExoPlayerCharacter : public AExoCharacterBase
|
||||||
{
|
{
|
||||||
|
|
@ -14,6 +17,12 @@ class EXO_API AExoPlayerCharacter : public AExoCharacterBase
|
||||||
public:
|
public:
|
||||||
AExoPlayerCharacter();
|
AExoPlayerCharacter();
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||||
|
TObjectPtr<UInteractionComponent> InteractionComponent;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||||
|
TObjectPtr<UShootingComponent> ShootingComponent;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
||||||
float DodgeForce = 5000.f;
|
float DodgeForce = 5000.f;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user