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"

[BUG] UPaperSpriteComponent disappears when compiling blueprint.

Hello,

I have created a pawn in C++ which contains a custom component (based on USceneComponent). This component contains a UPaperSpriteComponent. I then create a blueprint based on that pawn and set a sprite for the component, then modify some other attributes. When I compile the blueprint, the sprite disappears. I have created a new clean project to demonstrate the problem.

Here is a video of it in action: https://youtu.be/E8242ivR2Zo

Here is the code I have:

MySceneComponent.h

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #pragma once
 
 #include "Components/SceneComponent.h"
 #include "PaperSpriteComponent.h"
 #include "MySceneComponent.generated.h"
 
 
 UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
 class MYPROJECT_API UMySceneComponent : public USceneComponent
 {
     GENERATED_BODY()
 
 public:    
     // Sets default values for this component's properties
     UMySceneComponent();
 
     // Called when the game starts
     virtual void BeginPlay() override;
     
     // Called every frame
     virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     UPaperSpriteComponent* MySprite;
     
 };
 

MySceneComponent.cpp

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #include "MyProject.h"
 #include "MySceneComponent.h"
 
 
 // Sets default values for this component's properties
 UMySceneComponent::UMySceneComponent()
 {
     // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
     // off to improve performance if you don't need them.
     bWantsBeginPlay = true;
     PrimaryComponentTick.bCanEverTick = true;
 
     // ...
     MySprite = CreateDefaultSubobject<UPaperSpriteComponent>(TEXT("MySprite"));
     MySprite->SetupAttachment(this);
 }
 
 
 // Called when the game starts
 void UMySceneComponent::BeginPlay()
 {
     Super::BeginPlay();
 
     // ...
     
 }
 
 
 // Called every frame
 void UMySceneComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
 {
     Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
 
     // ...
 }
 
 

MyPawn.h

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #pragma once
 
 #include "GameFramework/Pawn.h"
 #include "MyPawn.generated.h"
 
 UCLASS()
 class MYPROJECT_API AMyPawn : public APawn
 {
     GENERATED_BODY()
 
 public:
     // Sets default values for this pawn's properties
     AMyPawn();
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;
 
     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
 
     UPROPERTY(EditAnywhere, BlueprintReadOnly)
     USceneComponent* RootSceneComponent;
 
     UPROPERTY(EditAnywhere, BlueprintReadOnly)
     class UMySceneComponent* MyComponent;
     
 };
 

MyPawn.cpp

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #include "MyProject.h"
 #include "MyPawn.h"
 #include "MySceneComponent.h"
 
 
 // Sets default values
 AMyPawn::AMyPawn()
 {
      // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
 
     RootSceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
     RootComponent = RootSceneComponent;
 
     MyComponent = CreateDefaultSubobject<UMySceneComponent>(TEXT("MyComponent"));
     MyComponent->SetupAttachment(RootComponent);
 
 }
 
 // Called when the game starts or when spawned
 void AMyPawn::BeginPlay()
 {
     Super::BeginPlay();
     
 }
 
 // Called every frame
 void AMyPawn::Tick( float DeltaTime )
 {
     Super::Tick( DeltaTime );
 
 }
 
 // Called to bind functionality to input
 void AMyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent)
 {
     Super::SetupPlayerInputComponent(InputComponent);
 
 }
 
 

As a side question, what are the appropriate attributes to set in the UPROPERTY macro when declaring components? Thank you for your support.

Product Version: UE 4.13
Tags:
more ▼

asked Sep 08 '16 at 05:11 PM in C++ Programming

avatar image

blen2r
23 2 3 8

avatar image blen2r Sep 08 '16 at 05:18 PM

One detail I can add. In my original project, MyComponent also contained a collider that was attached to the sprite component. When the sprite disappeared, the collider got reset to its default values so I suspect it's not simply a rendering problem.

avatar image JuanDAG May 10 '17 at 03:59 AM

Hello Everyone,

I know this is a current problem and many of us would like to get this code error fixed so that we can also learn how create games in 2D.

Please go into the bug report (which blen2r provided) and vote on it.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hey blen2r-

Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here (https://issues.unrealengine.com/issue/UE-35763 ). You can track the report's status as the issue is reviewed by our development staff.

Cheers

Doug Wilson

more ▼

answered Sep 08 '16 at 09:00 PM

(comments are locked)
10|2000 characters needed characters left
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