Actors vs. components

It may help to know that everything that moves in the world, moves via components. When actors are moved via SetActorLocation, AddActorWorldOffset, etc what is actually moved is their root component. Since components can be attached to each other, actors can be attached to components too which refers to attaching an actor’s root component to another component (owned by another actor).

The function SetChildActorClass is function for a specific type of component: a ChildActorComponent. What this component does is it spawns an actor of that class at game start and attaches it to itself. So actors can be attached to components but this is not the general use. The ChildActorComponent, when created in the blueprint editor and after setting the ChildActorClass, displays a preview of that actor. So that may help you in case you want to edit blueprints in which you have actors as children. I’m not sure how this works with multiple levels though (having a child actor that has child actors).

For your procedural generation task, I would use components for your blocks, but it also depends on the complexity of the behavior of the blocks. If you want your blocks to be heavily customizable in blueprint, then making them an actor might be a better option. But for now I’m just assuming you have blocks that just need to be rendered and have collision. In that case, use static meshes components or instanced static meshes components. Instanced static mesh components allow you to choose a mesh (a block in your case), a material and then very efficiently place multiple copies of those in your world. Instanced static mesh components are the way to go if your blocks have the same shape and material (or a small number of options). You can call AddInstance to specify a position where another one of the meshes should be shown.

For previewing generated stuff inside the editor, override the OnConstruction function (but don’t forget to call Super::OnConstruction):



	virtual void OnConstruction(const FTransform & Transform) override;


OnConstruction runs in the editor when your actor is placed, dragged, or detects a change in setting. If you place level generation logic in there (for example adding instances to your instanced static mesh component) they will show in your editor viewport.