Announcement

Collapse
No announcement yet.

Array of components

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Array of components

    I'm trying to create an array of components.
    However, each time I add new elements to an array in the constructor, they are simply not added. And when I compile the code, I get an error message that you have gone beyond the array (although this can not be).

    This is my code:

    PHP Code:
    UProceduralMeshComponentsection_1 CreateDefaultSubobject <UProceduralMeshComponent>(TEXT("Infinity"));
        
    mesh.Add(section_1);
        
    RootComponent mesh[0];

        
    UProceduralMeshComponentsection_2 CreateDefaultSubobject <UProceduralMeshComponent>(TEXT("Infinity2"));
        
    section_2->AttachToComponent(RootComponentFAttachmentTransformRules::KeepRelativeTransform);
        
    mesh.Add(section_2);

        
    UProceduralMeshComponentsection_3 CreateDefaultSubobject <UProceduralMeshComponent>(TEXT("Infinity3"));
        
    section_3->AttachToComponent(RootComponentFAttachmentTransformRules::KeepRelativeTransform);
        
    mesh.Add(section_3); 
    From the code you can see that I added three elements.
    However, the third element and more he does not add and errors appear.

    #2
    What does the declaration for your mesh variable look like.

    It should be something like TArray<UProicedueralMeshComponent *> mesh;

    Comment


      #3
      Originally posted by illYay View Post
      What does the declaration for your mesh variable look like.

      It should be something like TArray<UProicedueralMeshComponent *> mesh;
      Yep, so:

      PHP Code:
      UPROPERTY(EditAnywhereInstanced)
              
      TArray <class UProceduralMeshComponent*> mesh

      Comment

      Working...
      X