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"

Paper2d unable to see sprite after spawn in code

I am unable to see in the game spawned actors with paper 2d sprites when they are spawned, if I eject out of the game and edit properties the property suddenly shows. I've attempted to try and edit properties post spawning. All of the properties are initialised in a blueprint.

Before editing a property when actor is spawned. alt text

After editing a property when actor is spawned. alt text

This is the code that spawns it - apologies for it being messy I've been trying this for several hours...

Defaults

     PrimaryActorTick.bCanEverTick = true;
 
     SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComp"));
     SetRootComponent(SceneComponent);
 
     paperSprite = CreateDefaultSubobject<UPaperSpriteComponent>(TEXT("PaperSprite"));
     paperSprite->SetupAttachment(GetRootComponent());
     paperSprite->RegisterComponent();

Asteroid Spawner.

 void AAsteroidSpawner::SpawnAsteroid()
 {
     FVector spawnLoc = FVector(0,0,0);
     FRotator spawnRot = FRotator(0,0,0);
     FActorSpawnParameters params = FActorSpawnParameters();
     params.bDeferConstruction = false;
     params.Owner = this;
 
     AAsteroid* asteroid = GetWorld()->SpawnActor<AAsteroid>(AsteroidClass, spawnLoc, spawnRot, params);
     //asteroid->paperSprite->SetSprite(AsteroidClass->sprite);
     asteroid->UpdateComponentTransforms();
 }

Product Version: UE 4.21
Tags:
problem1.png (1.0 MB)
problem2.png (922.3 kB)
problem1.png (1.0 MB)
more ▼

asked Jan 19 '19 at 02:56 AM in C++ Programming

avatar image

Capitals
1 1 1

avatar image Capitals Jan 19 '19 at 11:20 AM

So I've managed to get this somewhat working, by setting the sprite, after spawning the object. However still if I spawn wanting to use my default values I come up with the same issues.

avatar image EnyeartBaed Feb 18 '19 at 02:26 PM

Yeah! The same problem was happened with me last time when I used this software. I really don’t have much knowledge to operate this software fully and feel helpless at the moment when this problem occurred. But after seeing that you’ve shared this Facebook profile Edubirdie article then I realize that good and helpful people are still there and we just need an eye to see them.

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

1 answer: sort voted first

paperSprite = CreateDefaultSubobject(TEXT("PaperSprite")); paperSprite->SetupAttachment(GetRootComponent()); paperSprite->RegisterComponent();

I am not understand.

more ▼

answered Feb 18 '19 at 02:49 PM

avatar image

Nancy Dane
0 2 2

(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