Code changes ruin blueprint

Hello everyone.

I have a class containing custom movement component and a blueprint derived from this class.
Component instance is created in the class constructor:

	MovementComponent = CreateDefaultSubobject<USimple2DMovement>(TEXT("2DMovement"));
	MovementComponent->UpdatedComponent = RootComponent;

And, well, when I make any changes in the code of the component, it sort of detaches from the blueprint:

As you can see, the “Details” tab is empty. When I create a new instance of the blueprint, this is what I see:

But this component is declared as a UPROPERTY in my code:

UPROPERTY(EditAnywhere, BlueprintReadWrite)
class USimple2DMovement *MovementComponent;

And while blueprint is broken, its parent class is working perfectly fine.

Does anyone have any idea how to solve the issue?

Try a full rebuild of your solution ( delete intermediate folder and binaries folder )

i suppose your class is based on actor and not pawn or character, but could you confirm ?

I tried full rebuild, unfortunately it didn’t help.

Currently I have following class structure:
Pawn → Character2D → Hero2D → Blueprint

i don’t recall exactly why, but i have this code for my mouvement component ( but my other components are registered in the classic way )

try something similar for your class

AWarcryPlayer::AWarcryPlayer(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass(AWarcryCharacter::CharacterMovementComponentName))
{

also, try without “UpdatedComponent” line ( might be not related, but you have to try any possibilities :slight_smile: )

Unfortunately, it doesn’t seem to be working.

UpdatedComponent line is important, without it movement component is pretty much useless(basically it sets an object to move).

ok, so now, try to make a new project with minimal code to see if you can repro the issue, if issue is still present, i suggest you to make a new post in bug section with test project :slight_smile:

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?