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/Components/ShootingComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "Player/InteractionComponent.h"
|
||||
|
||||
AExoPlayerCharacter::AExoPlayerCharacter()
|
||||
{
|
||||
GetCharacterMovement()->bSnapToPlaneAtStart = true;
|
||||
|
||||
InteractionComponent = CreateDefaultSubobject<UInteractionComponent>(TEXT("Interaction Component"));
|
||||
|
||||
ShootingComponent = CreateDefaultSubobject<UShootingComponent>(TEXT("Shooting Component"));
|
||||
|
||||
bUseControllerRotationPitch = true;
|
||||
bUseControllerRotationYaw = true;
|
||||
bUseControllerRotationRoll = false;
|
||||
|
|
@ -16,5 +23,5 @@ AExoPlayerCharacter::AExoPlayerCharacter()
|
|||
void AExoPlayerCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
check(InteractionComponent && ShootingComponent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ void AExoPlayerController::BeginPlay()
|
|||
InteractionComponent = PlayerCharacter->FindComponentByClass<UInteractionComponent>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
#include "Characters/ExoCharacterBase.h"
|
||||
#include "ExoPlayerCharacter.generated.h"
|
||||
|
||||
class UInteractionComponent;
|
||||
class UShootingComponent;
|
||||
|
||||
UCLASS()
|
||||
class EXO_API AExoPlayerCharacter : public AExoCharacterBase
|
||||
{
|
||||
|
|
@ -14,6 +17,12 @@ class EXO_API AExoPlayerCharacter : public AExoCharacterBase
|
|||
public:
|
||||
AExoPlayerCharacter();
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||
TObjectPtr<UInteractionComponent> InteractionComponent;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||
TObjectPtr<UShootingComponent> ShootingComponent;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
||||
float DodgeForce = 5000.f;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user