x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:

alt text

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

alt text

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?

Product Version: UE 4.17
Tags:
issue.jpg (87.1 kB)
bp.jpg (205.1 kB)
more ▼

asked Nov 06 '17 at 10:04 AM in Using UE4

avatar image

Iwrestledabeer
1 2 4

avatar image Firefly74 Nov 06 '17 at 10:14 AM

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 ?

avatar image Iwrestledabeer Nov 06 '17 at 10:29 AM

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

Currently I have following class structure: Pawn -> Character2D -> Hero2D -> Blueprint

avatar image Firefly74 Nov 06 '17 at 12:17 PM

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 :) )

avatar image Iwrestledabeer Nov 06 '17 at 05:08 PM

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).

avatar image Firefly74 Nov 06 '17 at 05:53 PM

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 :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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?

more ▼

answered Nov 07 '17 at 09:20 PM

avatar image

Iwrestledabeer
1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question