Automatic Actor placement

Automatic Actor placement

Hallo, I’m looking for an automatic Actor placement script that would place my meshes into the Viewport/Outliner based on a CSV file.

I’d like to use Editor Utility Blueprint for this. Not a Blueprint actor that you place into viewport and it draws objects after you run game.

I need something that will save me time with the manual actor placement into the scene so I can continue to edit it.

I have used BluePrint Structure to import the CSV file. This is how my example file looks.

Can anyone help me please?

1 Like

Hey there @playbuxa1! I’d recommend using a direct class reference for the actorBP you’re looking for and transform for your struct instead. I worked up a little sample to do exactly what you described in an editor utility widget.

My struct:

My DataTable:

My Editor Utility Widget BP:

The result:


Also the documentation I used:


Hope this helps!

2 Likes

Hi SupportiveEntity,

Thank you for your instructions.
Looks good, I will try it out!

Can you please show me how did you formated the input CSV file used for the inported data table?
I’m not able to import mine…

Thank you

No worries! The file pathing is odd sometimes. I’d recommend getting a path to your game’s folder at runtime and appending it so it’s not hardcoded like mine, but here’s how

I’m pulling from a CSV file:


image

Hi,
I’m sorry I mean the actual CSV file format. How shall I format the data please?
For example my format of he table was this.

I’m not sure how shall I format the data in the csv file to get your solution to work.

Thank you very much.

Create the necessary data struct in the engine, make a data table, add a dummy entry and export the DT to *.csv. Now you have an automagically formatted sample file you can add extras to.

Just to illustrate, export a test datatable out to the format you want with at least one test entry, and it will automatically generate a template for you.

hm… I’m doing something fundamentally wrong.

Can we take it step by step please?

  1. I create my structure asset


for ActtorClassReference I set the Actor → Class reference
for TransformToSpawn I set just Transform

  1. I create a dummy csv file in excel with this format, divided by comma not is separate cells
    csv

  2. I import the csv with the “Data Table Row Type” with the created data structure asset that I have created.

because it is a dummy csv it will give me an error at importing

but it will create a Data Table


I will have here:
row name - just as row number,
ActorClassReference is empty - because of the dummy csv error
Transform to spawn is being built from the Structure asset and is set with default values.

Is this correct so far please?
I’m not sure, because I can’t set the ActorClassreference to any mesh asset as you have on your picture.
You have there in ActorClassReference “BlueprintGeneratedClas’/Game/ThirdPerson/…something”
I do not see any option as this and can’t navigate to any mesh asset.

Thank you

No worries! I’ll just run through each step piece by piece. So first thing to do is to create your struct. I chose a Class reference and a transform reference since transform houses all you needed.

After this struct is made, I made a Data Table that’s just a placeholder that will give us a clear format. In mine I made 2 entries, but really you only really need at least one. You need to make a new entry, set it’s class reference and you can leave the transforms blank as they will always default to all 0 besides scale.
image

Then you’ll have at least one entry pointing at whatever class you want, but it needs to be set so you get the layout. It should look like this.

After that, save the data table, and go back to the content drawer and right click it, and export as CSV. Once you do, it will become a CSV file you can reference to be able to generate them how you’d like.

The resulting CSV will look a bit like this:

That is your template.

Then we make the Editor Utility Widget, same as before. However I had a different DataTable to populate here, I named the other one blank because it was in fact blank (to test the functionality clearly here).

image


and it’s activated via just a little button.

Last thing was opening the Editor Utility Widget, and clicking the button and verifying the test object spawns. I recommend also trying to use the template to add another so you can get the hang of it.

image

Let me know if you have any questions!

2 Likes

Hi SupportiveEntity,

I’m finally getting somewhere :slight_smile:

I’m able to spawn the BP class third person in my scene.
I’m also able to edit the exported file, add rows and edit the placement coordinated.
I can reimport the CSV file without errors.

However, I can’t reference any static mesh object in my library like the SM_Chair for example.

I see in your screenshot of the data table, that you have in both lines Blueprint class and you are calling a blueprint object.

If I want to navigate in the Datasheet to any Static Mesch (so I can see the SM class), I do not have such option. Only an default static mesh actor. And this is an empty actor without asigned mesh.

How can I address actual SM objects in from my library please?

Thank you,
regards PlayBuxa

No worries, so go back to the struct we made and change it to a static mesh object ref, then reexport the CSV template out before.

After that we make one small modification to the Blueprint. we change the class to a Static Mesh Actor and then take the structs data and send that on over to a Set Static Mesh.

Then voila:
image

1 Like

Than you very much SupputiceEntity!!!
it works great. I’m sooo happy.
Now it works as I need.

Thank you.

1 Like

Edit: i find that adding code like this within the construction script of blueprints makes more sense and then you can bake it down by converting them into packed level actors. I thought it didn’t work at first but it does, it will automatically bake down the construction script execution into components,

Hey there @0xKami! Your use case would be a bit closer to procedural generation than the setup I showed the user above. When working with simple procedural generation, you would want to have reference points on fence pieces to determine where you’d be able to place them. It shouldn’t have an issue in construction scripts, and you can even resimulate them by moving them in editor.

1 Like