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?) Spawned Actors Sneaking Out of a TArray in OnConstruction()

I have an ParentActor with a TArray of Actors

 UPROPERTY(EditAnywhere)
 TArray<AExampleActor*> ActorList;

I call OnConstruction and everything almost works fine except...

 void OnConstruction(const FTransform& Transform)
 {
     if (GetWorld() && ActorList.Num() == 0)
     {
         for (int Actor= 0; Actor< NumActors; ++Actor)
         {
             FTransform Translation = CalculateTranslation(Actor);
             FTransform SpawnTransform = Transform + Translation;
             AExampleActor* Tile = GetWorld()->SpawnActor<AExampleActor>(SpawnTransform.GetTranslation(), SpawnTransform.GetRotation().Rotator());
             AExampleActor->AttachToActor(this, FAttachmentTransformRules(EAttachmentRule::KeepWorld, false));
             ActorList.Add(Tile);
         }
     }
 }

I get one group of actors which are connected to the ParentActor as expected but I also get a second group of actors spawning which seem to have forgotten they have any attachment to the Parent . From the debugger it looks like this group is created when I initially click on the ParentActor in the editor but before I have dragged it into the world yet. Is this the expected behaviour?

Thanks

Product Version: UE 4.20
Tags:
more ▼

asked Oct 31 '18 at 08:52 PM in C++ Programming

avatar image

SausagesSizzling
8 1 3

avatar image mightyenigma Oct 31 '18 at 09:10 PM

I'm not sure but I think Actors get garbage-collected if they're not placed or spawned into the World.

avatar image anonymoussalt Jan 08 '19 at 08:01 PM

I have the same issue! Did you figure out the solution?

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

1 answer: sort voted first

Check for the transient flag which is set on preview actors. i.e. this->HasAnyFlags(EObjectFlags::RF_Transient)

more ▼

answered Jan 09 '19 at 12:07 AM

avatar image

anonymoussalt
181 3 9 36

(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