Automatically generate child actors with sequential parameter.

Hi, I have a base actor that I want to generate child actors from via ideally either a python or Blueprint utility script since I want to make hundreds of children, but don’t want to make them entirely by hand.

I’ve tired looking through the documents on blueprint utilities and python.

I can’t see anyway to actually make and save a child actor with blueprint utilities.
And on the python side, I’ve found things that make me think it’s possible, but nothing that walks me through it enough that I can actually understand with my current noob level understanding of python.

After much searching I finally found this:

Which gave me enough of a starting point to figure out my own answer.

While also using this:
https://docs.unrealengine.com/5.3/en-US/PythonAPI/class/EditorUtilityLibrary.html#unreal-editorutilitylibrary

In case someone else needs it here’s the code I used for my project:

What it does is break up a texture Atlas into actor blueprints based on a pre-made child blueprint.
I could never get any python tools to actually make a blueprint based on my own parent, it always gave me cryptic NoneType errors that had no answer no matter were I looked, so I worked around that by simply making the first child blueprint myself manually in unreal, and then duplicating it into all of the rest of the blueprints I need in python.

import unreal

# Get the BP to be duplicated
bp_asset = unreal.EditorUtilityLibrary.get_selected_assets()[0]
# Get the path to the BP to be dupplicated
bp_path = unreal.EditorUtilityLibrary.get_selected_asset_data()[0].package_name

# Generated class as string path and load it
bp_class = unreal.load_object(None, bp_asset.generated_class().get_path_name())

# Get the default object, which is the object from which we can call a function or modify a property
bp_cdo = unreal.get_default_object(bp_class)

#Get the number of tile actors that need to be made:
tmpGridSize = bp_cdo.get_editor_property("GridSize")
XTiles = bp_cdo.get_editor_property("ImageX") / tmpGridSize
YTiles = bp_cdo.get_editor_property("ImageY") / tmpGridSize
NumTiles = XTiles*YTiles
XName = 0
YName = 1



#Convert NumTiles From Float to Int, and then start the loop.
for _ in range(int(NumTiles)):
	#Make the name of the new asset based on the size of the tilemap:
	XName += 1
	if XName > XTiles:
		XName = 1
		YName += 1
	TmpName = "_" + str(XName) + "x" + str(YName)
	
	#Duplicate the asset
	bp_dupasset = unreal.EditorAssetLibrary.duplicate_loaded_asset(bp_asset, str(bp_path)+TmpName)
	# Get its generated class as string path and load it
	bp_dupclass = unreal.load_object(None, bp_dupasset.generated_class().get_path_name())
	# Get the default object
	bp_dupcdo = unreal.get_default_object(bp_dupclass)
	# Set the properties on the duplicate
	bp_dupcdo.set_editor_property("ShiftU", XName)
	bp_dupcdo.set_editor_property("ShiftV", YName)

	
unreal.log("All Actor Tiles Have Been Made")
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.