How to add multiple actors to Blueprint class?

I am new to Unreal. I have generated a Blueprint class that contains a particular tree. In that same class, I would like to add other different trees as well, so I can retrieve them at random and place them on the scene at runtime. However, I don’t know how to add actors/staticmeshes to a class.![alt text][1]

You can click on the mesh in the content browser, and then when you use the 'add… ’ menu in BP, the actor will be one of the options.

Alternatively, you can drag the mesh into the BP :slight_smile:

( One at a time, I think… )

If you are new to Unreal then probably you should read about Child Blueprints. Long story short - if you have generic Blueprint for all available “pickup” items in your game you should use Child Blueprints to create instances for all different versions of your pickups, not add all the variations to one Blueprint Class and then spawn random one at runtime.

For example in such situation you would have:

  • BP_Pickup (parent)
  • BP_Pickup_Health (child of BP_Pickup)
  • BP_Pickup_Ammo (child of BP_Pickup)
  • BP_Pickup_Armor (child of BP_Pickup)

All these items can be picked by the player (generic functionality, common for all the pickups and implemented in BP_Pickup) but Health, Ammo and Armor should have different effect (additional functionalities, implemented in specific pickups, children of BP_Pickup).

In your case you could have generic “BP_Tree” blueprint with all the functionalities common for all the trees in your game. Then you can create child blueprints from your generic tree blueprint for “BP_Orchard”, “BP_ChristmasTree” and all other types of trees.

Read more here:

If you want to toddle around the level randomly spawning different kinds of trees from one BP, I wouldn’t recommend the child route. It’s good to know about this, of course, but I think for what you want to do, making a BP with an array of static meshes ( of trees ) would be the answer.

Every time you spawn the BP, it chooses a mesh at random from the array. This can be in the construction script.

If you want to toddle around the level randomly spawning different kinds of trees from one BP, I wouldn’t recommend the child route. It’s good to know about this, of course, but I think for what you want to do, making a BP with an array of static meshes ( of trees ) would be the answer.

Every time you spawn the BP, it chooses a mesh at random from the array. This can be in the construction script.

Ok I have done something in the construction script

Now how do I link the output of the construction script to the level blueprint I created earlier. Also when I add another actor (Broadleaf_Desktop_Field_4) to the MyOrchards class, it is attached to the Orchard tree, how do I get one actor to spawn at a time?

You misunderstood me, sorry. Add meshes to the BP like this:

282003-variable-declaration.png

Then you can populate the arrary ( after compiling once ), like this:

Then you can randomly choose one in the construction script like this:

The BP only has one component, which is a mesh. But it doesn’t matter what that is ( for me it’s a cube ), because you’re overwriting it every time with a random one from the arrary…

282006-only-one-component.png

The meshes you see here are just me ALT dragging the BP, each time it changes the mesh:

Are you gettin’ it? :slight_smile:

1 Like

If you want to spawn it from the level BP, just use ‘spawn actor from class’ and type in the name of your BP.

Hi yeah sorted it out beforehand, forgot to mention. Sorry for wasting your time but thanks!