Hello world! I have this grid blueprint, where I have 100 cells in it. I would like to add a Box Collision component to each cell, however the only way I can find doing this, is by manually clicking each Cell (StaticMeshComponent) and then clicking “Add component” and the adding the “Box Collision” component:
- Is there a way I can somehow add the component via script? I tried to do write the following code in the constructor,
TArray<UStaticMeshComponent*> StaticMeshComponents; GetComponents<UStaticMeshComponent>(StaticMeshComponents);
so I can use “CreateDefaultSubobject<UBoxComponent>
” under each Cell (StaticMeshComponent). BUT the problem with that is that the TArray<UStaticMeshComponent* > StaticMeshComponents is empty as the Cells are not yet initialized by the time the constructor is executed.
- The other thing I tried was to select all Cells (StaticMeshComponent) in the and try to click add box collision, but it adds the new box collision component to only 1 of the 100 selected Cells.
What would you suggest doing in this case? Also MAYBE I have to setup the whole grid in a different way so I can edit the Cells themselves? But in that case how can I make it so they have exactly the asthetic view I want them to have achieved from Maya?
I also tried creating this blueprint construction function, which creates the components, but I can only see their outline and can not select them so I can edit them in the editor: