Hello again, I wanted to add some details about the issue.
I have following class structure:
Pawn → Character2D → Hero2D → Blueprint
Character2D class contains capsule component, flipbook component, custom movement component(derived from MovementComponent) and custom attack component(derived from ActorComponent).
They all declared in the header of Character2D class in the same way:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UPaperFlipbookComponent *FlipbookComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UCapsuleComponent *CapsuleComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class USimple2DMovement *MovementComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UAttackComponent *AttackComponent;
This is how ACharacter2D() constructor looks like:
ACharacter2D::ACharacter2D()
{
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bStartWithTickEnabled = true;
CapsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("RootCapsule"));
CapsuleComponent->bGenerateOverlapEvents = true;
CapsuleComponent->SetNotifyRigidBodyCollision(true);
CapsuleComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
CapsuleComponent->SetCollisionObjectType(ECC_Pawn);
CapsuleComponent->SetCollisionResponseToAllChannels(ECR_Ignore);
CapsuleComponent->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block);
CapsuleComponent->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
CapsuleComponent->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
this->OnActorHit.AddDynamic(this, &ACharacter2D::OnHit);
RootComponent = CapsuleComponent;
FlipbookComponent = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("FlipBook"));
FlipbookComponent->SetupAttachment(RootComponent);
FlipbookComponent->SetRelativeLocation(FVector::ZeroVector);
MovementComponent = CreateDefaultSubobject<USimple2DMovement>(TEXT("2DMovement"));
MovementComponent->UpdatedComponent = RootComponent;
AttackComponent = CreateDefaultSubobject<UAttackComponent>(TEXT("Attack"));
}
Well, the issue I’m facing is already described above, but I’ll repeat.
Changes of movement component break my blueprint.
Every time I add or delete some variable, the component detaches from blueprint. Any usual measures like rebuilding project/reparenting blueprint don’t help.
By the way, changes of my attack component are always flawlessly reflected in the blueprint and, well, I have no idea why the issue occurs with movement component only, while attack component is being updated without issues whatsoever.
Here is a part of movement component header:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/MovementComponent.h"
#include "Engine.h"
#include "Simple2DMovement.generated.h"
struct F_Timer
{
float CurrentTime, TargetTime;
bool Expired()
{
return CurrentTime >= TargetTime;
}
F_Timer() : CurrentTime(0), TargetTime(0) {}
F_Timer(float Target) : CurrentTime(0), TargetTime(Target) {}
};
UCLASS()
class FRANCIS_API USimple2DMovement : public UMovementComponent
{
GENERATED_BODY()
public:
USimple2DMovement();
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
virtual void SetUpdatedComponent(USceneComponent* NewUpdatedComponent) override;
void SetHit(const FHitResult &Hit);
void AddDash(const FVector2D &Dash);
etc.
And a part of attack component header:
#pragma once
#include "CoreMinimal.h"
#include "Attack.h"
#include "Components/ActorComponent.h"
#include "AttackComponent.generated.h"
UCLASS()
class FRANCIS_API UAttackComponent : public UActorComponent
{
GENERATED_BODY()
public:
UAttackComponent();
protected:
virtual void BeginPlay() override;
public:
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
void Attack();
FVector2D GetDash() const;
etc.
The only (probably) significant difference I see is a structure definition before movement component class declaration, but I don’t think it’s that important.
Does anyone have any idea why movement component causes issues and attack component doesn’t?